Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<!-- mono-symbolicate is not supported -->
<MonoSymbolArchive>false</MonoSymbolArchive>
<AndroidCodegenTarget Condition=" '$(AndroidCodegenTarget)' == '' ">XAJavaInterop1</AndroidCodegenTarget>
<!--
Disable @(Content) from referenced projects
See: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L16
-->
<_GetChildProjectCopyToPublishDirectoryItems>false</_GetChildProjectCopyToPublishDirectoryItems>
</PropertyGroup>

<!-- User-facing configuration-specific defaults -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1484,21 +1484,55 @@ public void BuildBasicApplicationCheckConfigFiles ()
}

[Test]
public void BuildApplicationCheckItEmitsAWarningWithContentItems ()
public void CheckContentBuildAction ()
{
var proj = new XamarinAndroidApplicationProject ();
using (var b = CreateApkBuilder ("temp/BuildApplicationCheckItEmitsAWarningWithContentItems")) {
b.ThrowOnBuildFailure = false;
var metadata = "CopyToOutputDirectory=PreserveNewest";
var path = Path.Combine ("temp", TestName);

var lib = new XamarinAndroidLibraryProject {
ProjectName = "Library1",
Sources = {
new BuildItem.Source ("Bar.cs") {
TextContent = () => "public class Bar { }"
},
},
OtherBuildItems = {
new BuildItem.Content ("TestContent.txt") {
TextContent = () => "Test Content from Library",
MetadataValues = metadata,
}
}
};

var proj = new XamarinAndroidApplicationProject {
ProjectName = "App",
Sources = {
new BuildItem.Source ("Foo.cs") {
TextContent = () => "public class Foo : Bar { }"
},
},
References = {
new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj"),
}
};
using (var libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName)))
using (var appBuilder = CreateApkBuilder (Path.Combine (path, proj.ProjectName))) {
Assert.IsTrue (libBuilder.Build (lib), "library should have built successfully");
StringAssertEx.Contains ("TestContent.txt : warning XA0101: @(Content) build action is not supported", libBuilder.LastBuildOutput,
"Build Output did not contain 'TestContent.txt : warning XA0101'.");

proj.AndroidResources.Add (new BuildItem.Content ("TestContent.txt") {
TextContent = () => "Test Content"
TextContent = () => "Test Content",
MetadataValues = metadata,
});
proj.AndroidResources.Add (new BuildItem.Content ("TestContent1.txt") {
TextContent = () => "Test Content 1"
TextContent = () => "Test Content 1",
MetadataValues = metadata,
});
Assert.IsTrue (b.Build (proj), "Build should have built successfully");
StringAssertEx.Contains ("TestContent.txt : warning XA0101: @(Content) build action is not supported", b.LastBuildOutput,
Assert.IsTrue (appBuilder.Build (proj), "app should have built successfully");
StringAssertEx.Contains ("TestContent.txt : warning XA0101: @(Content) build action is not supported", appBuilder.LastBuildOutput,
"Build Output did not contain 'TestContent.txt : warning XA0101'.");
StringAssertEx.Contains ("TestContent1.txt : warning XA0101: @(Content) build action is not supported", b.LastBuildOutput,
StringAssertEx.Contains ("TestContent1.txt : warning XA0101: @(Content) build action is not supported", appBuilder.LastBuildOutput,
"Build Output did not contain 'TestContent1.txt : warning XA0101'.");
}
}
Expand Down
12 changes: 0 additions & 12 deletions tests/Mono.Android-Tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@
DependsOnTargets="_CreateJavaInteropDllConfigs">
</Target>

<!-- When we build the multitargeted Java.Interop project as a dependency of this test project we hit the following error:
error NETSDK1148: Found multiple publish output files with the same relative path: external\Java.Interop\bin\Release\java-interop.jar, \external\Java.Interop\bin\Release-netcoreapp3.1\java-interop.jar.
We do not need to include any of this content in the output directory, so remove it here:
-->
<Target Name="RemoveJavaInteropJarContent"
Condition=" '$(TargetFramework)' == 'net6.0-android' "
BeforeTargets="ComputeResolvedFilesToPublishList" >
<ItemGroup>
<ResolvedFileToPublish Remove="$(JavaInteropSourceDirectory)\bin\**\java-interop.jar" />
</ItemGroup>
</Target>

<Target Name="GenerateNuGetConfig" >
<PropertyGroup>
<LocalNupkgDirectory Condition=" '$(LocalNupkgDirectory)' == '' ">$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nupkgs\</LocalNupkgDirectory>
Expand Down