Skip to content

Commit d155b8f

Browse files
authored
[9.0.2xx] Avoid warning about empty NuGetPackageRoot in wpftmp projects (#44688)
2 parents bda713d + 85d7113 commit d155b8f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets

+3-2
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,10 @@ Copyright (c) .NET Foundation. All rights reserved.
263263
Condition="'$(_MicrosoftNetSdkCompilersToolsetPackageRootEmpty)' != 'true' and !Exists('$(RoslynTargetsPath)')"
264264
FormatArguments="$(NETCoreSdkVersion)" />
265265

266-
<!-- Warn if $(NuGetPackageRoot) is empty. See https://github.com/dotnet/sdk/issues/43016. -->
266+
<!-- Warn if $(NuGetPackageRoot) is empty. See https://github.com/dotnet/sdk/issues/43016.
267+
WPF temp projects are ignored (it's known their NuGetPackageRoot is empty and user cannot fix that anyway). -->
267268
<NETSdkWarning ResourceName="MicrosoftNetSdkCompilersToolsetRootEmpty"
268-
Condition="'$(_MicrosoftNetSdkCompilersToolsetPackageRootEmpty)' == 'true'" />
269+
Condition="'$(_MicrosoftNetSdkCompilersToolsetPackageRootEmpty)' == 'true' and !($(MSBuildProjectFile.EndsWith('_wpftmp.csproj')) or $(MSBuildProjectFile.EndsWith('_wpftmp.vbproj')))" />
269270
</Target>
270271

271272
<!-- TODO: this target should not check GeneratePackageOnBuild.

test/Microsoft.NET.Restore.Tests/GivenThatWeWantToUseFrameworkRoslyn.cs

+21
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,26 @@ public void It_throws_a_warning_when_NuGetPackageRoot_is_empty()
160160
var toolsetPackageDir = Path.Combine(customPackagesDir, "microsoft.net.sdk.compilers.toolset");
161161
new DirectoryInfo(toolsetPackageDir).Should().Exist();
162162
}
163+
164+
[FullMSBuildOnlyFact] // https://github.com/dotnet/sdk/issues/44605
165+
public void It_does_not_throw_a_warning_when_NuGetPackageRoot_is_empty_in_wpftmp()
166+
{
167+
var testAsset = _testAssetsManager
168+
.CopyTestAsset("DesktopWpf")
169+
.WithSource();
170+
171+
NuGetConfigWriter.Write(testAsset.Path, TestContext.Current.TestPackages);
172+
173+
var buildCommand = new BuildCommand(testAsset, relativePathToProject: "FxWpf")
174+
{
175+
WorkingDirectory = Path.Combine(testAsset.Path, "FxWpf")
176+
};
177+
178+
// simulate mismatched MSBuild versions via _IsDisjointMSBuildVersion
179+
buildCommand.Execute("-p:_IsDisjointMSBuildVersion=true")
180+
.Should().Pass().And.NotHaveStdOutContaining("NETSDK1221");
181+
182+
Assert.True(File.Exists(Path.Combine(testAsset.Path, "obj", "net472", "MainWindow.g.cs")));
183+
}
163184
}
164185
}

0 commit comments

Comments
 (0)