Skip to content

Commit

Permalink
Revert "[Xamarin.Android.Build.Tasks] fix cases of missing `@(Referen…
Browse files Browse the repository at this point in the history
…ce)` (dotnet#7642)" (dotnet#7726)

This reverts commit 22f2001.

.NET MAUI is hitting a build failure such as:

    Unable to open file 'obj\Release\net8.0-android\android-x64\aot\x86_64\Microsoft.Maui.Controls.resources\temp.s': Permission denied

In 22f2001, we began passing satellite assemblies to the AOT compiler,
on accident? I am unsure how a test in xamarin-android didn't catch
this, but it may be something that only happens via a
`@(ProjectReference)` as occurred in .NET MAUI.

For now, let's revert the change and revisit later.

We should reopen dotnet/maui#10154 after
this is merged.
  • Loading branch information
jonathanpeppers authored Jan 22, 2023
1 parent baa5a73 commit c1efcb5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ _ResolveAssemblies MSBuild target.
</PropertyGroup>

<Target Name="_ComputeFilesToPublishForRuntimeIdentifiers"
DependsOnTargets="BuildOnlySettings;_FixupIntermediateAssembly;ResolveReferences;ComputeFilesToPublish;$(_RunAotMaybe)"
DependsOnTargets="_FixupIntermediateAssembly;ResolveReferences;ComputeFilesToPublish;$(_RunAotMaybe)"
Returns="@(ResolvedFileToPublish)">
<ItemGroup>
<ResolvedFileToPublish Remove="@(_SourceItemsToCopyToPublishDirectory)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,67 +1079,6 @@ public void DotNetIncremental ([Values (true, false)] bool isRelease, [Values ("
}
}

[Test]
public void ProjectDependencies ([Values(true, false)] bool projectReference)
{
// Setup dependencies App A -> Lib B -> Lib C
var path = Path.Combine ("temp", TestName);

var libB = new XASdkProject (outputType: "Library") {
ProjectName = "LibraryB",
IsRelease = true,
};
libB.Sources.Clear ();
libB.Sources.Add (new BuildItem.Source ("Foo.cs") {
TextContent = () => @"public class Foo {
public Foo () {
var bar = new Bar();
}
}",
});

var libC = new XASdkProject (outputType: "Library") {
ProjectName = "LibraryC",
IsRelease = true,
};
libC.Sources.Clear ();
libC.Sources.Add (new BuildItem.Source ("Bar.cs") {
TextContent = () => "public class Bar { }",
});

// Add a @(Reference) or @(ProjectReference)
if (projectReference) {
libB.AddReference (libC);
} else {
libB.OtherBuildItems.Add (new BuildItem.Reference ($@"..\{libC.ProjectName}\bin\Release\{libC.TargetFramework}\{libC.ProjectName}.dll"));
}

// Build libraries
var libCBuilder = CreateDotNetBuilder (libC, Path.Combine (path, libC.ProjectName));
Assert.IsTrue (libCBuilder.Build (), $"{libC.ProjectName} should succeed");
var libBBuilder = CreateDotNetBuilder (libB, Path.Combine (path, libB.ProjectName));
Assert.IsTrue (libBBuilder.Build (), $"{libB.ProjectName} should succeed");

var appA = new XASdkProject {
ProjectName = "AppA",
IsRelease = true,
Sources = {
new BuildItem.Source ("Bar.cs") {
TextContent = () => "public class Bar : Foo { }",
}
}
};
appA.AddReference (libB);
var appBuilder = CreateDotNetBuilder (appA, Path.Combine (path, appA.ProjectName));
Assert.IsTrue (appBuilder.Build (), $"{appA.ProjectName} should succeed");

var apkPath = Path.Combine (FullProjectDirectory, appA.OutputPath, $"{appA.PackageName}-Signed.apk");
FileAssert.Exists (apkPath);
var helper = new ArchiveAssemblyHelper (apkPath);
helper.AssertContainsEntry ($"assemblies/{libB.ProjectName}.dll");
helper.AssertContainsEntry ($"assemblies/{libC.ProjectName}.dll");
}

[Test]
public void DotNetDesignTimeBuild ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2006,8 +2006,7 @@ because xbuild doesn't support framework reference assemblies.
DependsOnTargets="_ResolveAssemblies"
>
<ItemGroup>
<!-- In .NET 6+, the .NET SDK locates these files -->
<_AndroidResolvedSatellitePaths Condition=" '$(UsingAndroidNETSdk)' != 'true' " Include="@(ReferenceSatellitePaths)" />
<_AndroidResolvedSatellitePaths Include="@(ReferenceSatellitePaths)" />
<!-- Satellites from the current project, see: https://github.com/microsoft/msbuild/blob/master/src/Tasks/Microsoft.Common.CurrentVersion.targets#L4283-L4299 -->
<_AndroidResolvedSatellitePaths Include="@(IntermediateSatelliteAssembliesWithTargetPath->'$(OutDir)%(Culture)\$(TargetName).resources.dll')" />
</ItemGroup>
Expand Down

0 comments on commit c1efcb5

Please sign in to comment.