diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 311632f9c331..c10947d9cdc6 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -85,13 +85,13 @@
https://github.com/dotnet/runtime
255eea008147245df48aaa1fae60eb92519f1dc3
-
+
https://github.com/dotnet/windowsdesktop
- 37c6a8e306022848c661d9e38b99633f1ce11141
+ 47d20bf0c3dd54f84e678c987db33c7ac95bb2f6
-
+
https://github.com/dotnet/wpf
- e7cad628c82f8761cac2070c80601ae8e75139a6
+ e36c6981d99317ffdfe0bcc9f1f264f59a29793d
https://github.com/dotnet/aspnetcore
diff --git a/eng/Versions.props b/eng/Versions.props
index a87e09a752a1..51bba2b2e4f2 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -127,11 +127,11 @@
- 5.0.0-preview.8.20352.4
+ 5.0.0-preview.8.20358.1
- 5.0.0-preview.8.20352.5
+ 5.0.0-preview.8.20358.1
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props
index 74a3a0358ecd..2134545601d1 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props
@@ -128,6 +128,6 @@ Copyright (c) .NET Foundation. All rights reserved.
-
+
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets
index 345f0b71366d..37eff468fa40 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets
@@ -992,5 +992,5 @@ Copyright (c) .NET Foundation. All rights reserved.
-
+
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs
index fb7b109679f0..a5fef6f64cbd 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs
@@ -154,6 +154,141 @@ public void It_does_not_download_desktop_runtime_packs_on_unix()
.NotHaveSubDirectories($"runtime.{Rid}.microsoft.windowsdesktop.app");
}
+ [Theory]
+ [InlineData("net5.0", "TargetPlatformIdentifier", "Windows", "WinExe")]
+ [InlineData("netcoreapp3.1", "UseWindowsForms", "true", "WinExe")]
+ [InlineData("netcoreapp3.1", "UseWPF", "true", "WinExe")]
+ [InlineData("netcoreapp3.1", "UseWPF", "false", "Exe")]
+ public void It_infers_WinExe_output_type(string targetFramework, string propName, string propValue, string expectedOutputType)
+ {
+ var testProject = new TestProject()
+ {
+ Name = "WinExeOutput",
+ TargetFrameworks = targetFramework,
+ IsSdkProject = true,
+ IsExe = true,
+ };
+ testProject.AdditionalProperties[propName] = propValue;
+ testProject.AdditionalProperties["TargetPlatformVersion"] = "7.0"; // Ensure TargetPlatformVersion is set so we can build with a TargetPlatformIdentifier
+
+ var asset = _testAssetsManager.CreateTestProject(testProject);
+
+ var getValuesCommand = new GetValuesCommand(asset, "OutputType");
+ getValuesCommand
+ .Execute()
+ .Should()
+ .Pass();
+
+ var values = getValuesCommand.GetValues();
+ values.Count.Should().Be(1);
+ values.First().Should().Be(expectedOutputType);
+ }
+
+ [WindowsOnlyFact]
+ public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_with_ProjectSdk_set()
+ {
+ const string ProjectName = "WindowsDesktopSdkTest_50";
+
+ const string tfm = "net5.0";
+
+ var testProject = new TestProject()
+ {
+ Name = ProjectName,
+ TargetFrameworks = tfm,
+ IsSdkProject = true,
+ ProjectSdk = "Microsoft.NET.Sdk.WindowsDesktop",
+ IsWinExe = true,
+ };
+
+ testProject.SourceFiles.Add("App.xaml.cs", _fileUseWindowsType);
+ testProject.AdditionalProperties.Add("UseWPF", "true");
+
+ var asset = _testAssetsManager.CreateTestProject(testProject);
+
+ var command = new BuildCommand(Log, Path.Combine(asset.Path, ProjectName));
+
+ command
+ .Execute()
+ .Should()
+ .Pass();
+ }
+
+ [WindowsOnlyFact]
+ public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_without_ProjectSdk_set()
+ {
+ const string ProjectName = "WindowsDesktopSdkTest_without_ProjectSdk_set";
+
+ const string tfm = "net5.0";
+
+ var testProject = new TestProject()
+ {
+ Name = ProjectName,
+ TargetFrameworks = tfm,
+ IsSdkProject = true,
+ IsWinExe = true,
+ };
+
+ testProject.SourceFiles.Add("App.xaml.cs", _fileUseWindowsType);
+ testProject.AdditionalProperties.Add("UseWPF", "true");
+ testProject.AdditionalProperties.Add("TargetPlatformIdentifier", "Windows");
+
+ var asset = _testAssetsManager.CreateTestProject(testProject);
+
+ var command = new BuildCommand(Log, Path.Combine(asset.Path, ProjectName));
+
+ command
+ .Execute()
+ .Should()
+ .Pass();
+ }
+
+ [WindowsOnlyFact]
+ public void When_TargetPlatformVersion_is_set_higher_than_10_It_can_reference_cswinrt_api()
+ {
+ const string ProjectName = "WindowsDesktopSdkTest_without_ProjectSdk_set";
+
+ const string tfm = "net5.0";
+
+ var testProject = new TestProject()
+ {
+ Name = ProjectName,
+ TargetFrameworks = tfm,
+ IsSdkProject = true,
+ IsWinExe = true,
+ };
+
+ testProject.SourceFiles.Add("Program.cs", _useCsWinrtApi);
+ testProject.AdditionalProperties.Add("TargetPlatformIdentifier", "Windows");
+ testProject.AdditionalProperties.Add("TargetPlatformVersion", "10.0.17763");
+
+ var asset = _testAssetsManager.CreateTestProject(testProject);
+
+ var buildCommand = new BuildCommand(Log, Path.Combine(asset.Path, ProjectName));
+
+ buildCommand.Execute()
+ .Should()
+ .Pass();
+
+ void Assert(DirectoryInfo outputDir)
+ {
+ outputDir.File("Microsoft.Windows.SDK.NET.dll").Exists.Should().BeTrue("The output has cswinrt dll");
+ outputDir.File("WinRT.Runtime.dll").Exists.Should().BeTrue("The output has cswinrt dll");
+ var runtimeconfigjson = File.ReadAllText(outputDir.File(ProjectName + ".runtimeconfig.json").FullName);
+ runtimeconfigjson.Contains(@"""name"": ""Microsoft.NETCore.App""").Should().BeTrue("runtimeconfig.json only reference Microsoft.NETCore.App");
+ runtimeconfigjson.Contains("Microsoft.Windows.SDK.NET").Should().BeFalse("runtimeconfig.json does not reference windows SDK");
+ }
+
+ Assert(buildCommand.GetOutputDirectory(tfm));
+
+ var publishCommand = new PublishCommand(Log, Path.Combine(asset.Path, ProjectName));
+ var runtimeIdentifier = "win-x64";
+ publishCommand.Execute("-p:SelfContained=true", $"-p:RuntimeIdentifier={runtimeIdentifier}")
+ .Should()
+ .Pass();
+
+ Assert(publishCommand.GetOutputDirectory(tfm, runtimeIdentifier: runtimeIdentifier));
+ }
+
private TestAsset CreateWindowsDesktopSdkTestAsset(string projectName, string uiFrameworkProperty)
{
const string tfm = "netcoreapp3.0";
@@ -189,34 +324,39 @@ private TestAsset CreateWindowsDesktopReferenceTestAsset(string projectName, str
return _testAssetsManager.CreateTestProject(testProject);
}
- [Theory]
- [InlineData("net5.0", "TargetPlatformIdentifier", "Windows", "WinExe")]
- [InlineData("netcoreapp3.1", "UseWindowsForms", "true", "WinExe")]
- [InlineData("netcoreapp3.1", "UseWPF", "true", "WinExe")]
- [InlineData("netcoreapp3.1", "UseWPF", "false", "Exe")]
- public void It_infers_WinExe_output_type(string targetFramework, string propName, string propValue, string expectedOutputType)
- {
- var testProject = new TestProject()
- {
- Name = "WinExeOutput",
- TargetFrameworks = targetFramework,
- IsSdkProject = true,
- IsExe = true,
- };
- testProject.AdditionalProperties[propName] = propValue;
- testProject.AdditionalProperties["TargetPlatformVersion"] = "7.0"; // Ensure TargetPlatformVersion is set so we can build with a TargetPlatformIdentifier
+ private readonly string _fileUseWindowsType = @"
+using System.Windows;
- var asset = _testAssetsManager.CreateTestProject(testProject);
+namespace wpf
+{
+ public partial class App : Application
+ {
+ }
- var getValuesCommand = new GetValuesCommand(asset, "OutputType");
- getValuesCommand
- .Execute()
- .Should()
- .Pass();
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ }
+ }
+}
+";
- var values = getValuesCommand.GetValues();
- values.Count.Should().Be(1);
- values.First().Should().Be(expectedOutputType);
+ private readonly string _useCsWinrtApi = @"
+using System;
+using Windows.Data.Json;
+
+namespace consolecswinrt
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ var rootObject = JsonObject.Parse(""{\""greet\"": \""Hello\""}"");
+ Console.WriteLine(rootObject[""greet""]);
}
}
}
+";
+ }
+}