Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Commit 683f375

Browse files
authored
[Microsoft.Android.Build] Use MSBuild NuGets (#118)
Context: dotnet/android#5891 I've been hitting errors running tests locally on Windows after building with .NET 6 Preview 3: Error Message: System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Stack Trace: at Xamarin.ProjectTools.DotNetXamarinProject.SaveProject() at Xamarin.ProjectTools.XamarinProject.Save(Boolean saveProject) in C:\Users\Peter\source\xamarin-android\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Common\XamarinProject.cs:line 241 at Xamarin.ProjectTools.ProjectBuilder.Save(XamarinProject project, Boolean doNotCleanupOnUpdate, Boolean saveProject) in C:\Users\Peter\source\xamarin-android\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Common\ProjectBuilder.cs:line 43 at Xamarin.ProjectTools.ProjectBuilder.Build(XamarinProject project, Boolean doNotCleanupOnUpdate, String[] parameters, Boolean saveProject, Dictionary`2 environmentVariables) in C:\Users\Peter\source\xamarin-android\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Common\ProjectBuilder.cs:line 67 at Xamarin.Android.Build.Tests.WearTests.ResolveLibraryImportsWithReadonlyFiles() in C:\Users\Peter\source\xamarin-android\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\WearTests.cs:line 28 Rather than copying the version of the MSBuild assemblies used to build our test projects to the output directory, we should be able to use the NuGet package content directly. These files should only be used by our project creation APIs and as a result their version shouldn't matter.
1 parent 2241489 commit 683f375

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

‎src/Microsoft.Android.Build.BaseTasks/MSBuildReferences.projitems‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
</PropertyGroup>
1111

1212
<ItemGroupCondition="$([MSBuild]::IsOSPlatform('windows'))" >
13-
<!-- Compile against Microsoft.Build* NuGet refs, but do not copy to OutputDir. -->
1413
<!-- Only use these on Windows as it causes problems with running unit tests in the IDE's on MacOS -->
15-
<PackageReferenceInclude="Microsoft.Build"Version="$(MSBuildPackageReferenceVersion)"IncludeAssets="compile"/>
16-
<PackageReferenceInclude="Microsoft.Build.Framework"Version="$(MSBuildPackageReferenceVersion)"IncludeAssets="compile"/>
17-
<PackageReferenceInclude="Microsoft.Build.Tasks.Core"Version="$(MSBuildPackageReferenceVersion)"IncludeAssets="compile"/>
18-
<PackageReferenceInclude="Microsoft.Build.Utilities.Core"Version="$(MSBuildPackageReferenceVersion)"IncludeAssets="compile"/>
14+
<PackageReferenceInclude="Microsoft.Build"Version="$(MSBuildPackageReferenceVersion)" />
15+
<PackageReferenceInclude="Microsoft.Build.Framework"Version="$(MSBuildPackageReferenceVersion)" />
16+
<PackageReferenceInclude="Microsoft.Build.Tasks.Core"Version="$(MSBuildPackageReferenceVersion)" />
17+
<PackageReferenceInclude="Microsoft.Build.Utilities.Core"Version="$(MSBuildPackageReferenceVersion)" />
1918
</ItemGroup>
2019

2120
<ItemGroupCondition="!$([MSBuild]::IsOSPlatform('windows'))">
@@ -49,12 +48,4 @@
4948
<PackageReferenceInclude="System.ValueTuple"Version="4.5.0" />
5049
</ItemGroup>
5150

52-
<ItemGroupCondition="$([MSBuild]::IsOSPlatform('windows'))" >
53-
<!-- Copy system Microsoft.Build*.dll and dependencies for tests to run against. We can remove this
54-
and rely entirely on NuGet assets when mono/msbuild is merged into microsoft/msbuild. -->
55-
<NoneInclude="$(MSBuildToolsPath)\Microsoft.Build*.dll" >
56-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
57-
</None>
58-
</ItemGroup>
59-
6051
</Project>

0 commit comments

Comments
 (0)