Skip to content

Commit e937a47

Browse files
[One .NET] <FixNuGetReferences/> should also work for netstandard2.1 (#5680)
I was attempting to build a project using some brand new Maui NuGet packages and hit errors such as: The type or namespace name 'MauiAppCompatActivity' could not be found The type or namespace name 'MauiApplication<>' could not be found These types are in: %userprofile%\.nuget\packages\microsoft.maui.core\6.0.100-preview.2.179\lib\net6.0-android30.0\Microsoft.Maui.dll Unfortunately, the build actually used the `netstandard2.1` assembly: %userprofile%\.nuget\packages\microsoft.maui.core\6.0.100-preview.2.179\lib\netstandard2.1\Microsoft.Maui.dll Our temporary `<FixNuGetReferences/>` MSBuild task should be what selects the correct assembly, but it didn't. When we have full NuGet `$(TFM)` support, we won't need this task at all. After reviewing the code, I think we need to instead use `directoryName.StartsWith("netstandard2")`. I will add a test for this scenario when we have Maui packages we can consume from a feed. We should build a sample Maui app on our CI.
1 parent a75e4c2 commit e937a47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/FixupNuGetReferences.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public override bool RunTask ()
3838
var directory = Path.GetDirectoryName (item.ItemSpec);
3939
var directoryName = Path.GetFileName (directory);
4040
Log.LogDebugMessage ($"{directoryName} -> {item.ItemSpec}");
41-
if (directoryName == "netstandard2.0") {
41+
if (directoryName.StartsWith ("netstandard2", StringComparison.OrdinalIgnoreCase)) {
4242
var parent = Directory.GetParent (directory);
4343
foreach (var nugetDirectory in parent.EnumerateDirectories ()) {
4444
var name = Path.GetFileName (nugetDirectory.Name);

0 commit comments

Comments
 (0)