From 0d31be029bd876bf57ca8bae5c2e438f90c04035 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Wed, 8 Jul 2020 12:08:26 +0000 Subject: [PATCH 1/7] Update dependencies from https://github.com/dotnet/windowsdesktop build 20200707.4 Microsoft.WindowsDesktop.App From Version 5.0.0-preview.8.20352.5 -> To Version 5.0.0-preview.8.20357.4 Dependency coherency updates Microsoft.NET.Sdk.WindowsDesktop From Version 5.0.0-preview.8.20352.4 -> To Version 5.0.0-preview.8.20357.5 (parent: Microsoft.WindowsDesktop.App --- eng/Version.Details.xml | 8 ++++---- eng/Versions.props | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index eb78ed39f797..80b7cde0d9fa 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -85,13 +85,13 @@ https://github.com/dotnet/runtime 3155ca2dfa20e11949f24e439b54ba1816be3c22 - + https://github.com/dotnet/windowsdesktop - 37c6a8e306022848c661d9e38b99633f1ce11141 + 130adb291e6cc6efa8ab14989f5b2527adedac2b - + https://github.com/dotnet/wpf - e7cad628c82f8761cac2070c80601ae8e75139a6 + 96b36ed9cb7b41e127c94ca445ac4b4e46789999 https://github.com/dotnet/aspnetcore diff --git a/eng/Versions.props b/eng/Versions.props index 415dc06134db..b55038cabc98 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.20357.5 - 5.0.0-preview.8.20352.5 + 5.0.0-preview.8.20357.4 From a8bf057cf93a30fa4eda2774eb9ca9fb24d835ff Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Wed, 8 Jul 2020 23:04:27 -0700 Subject: [PATCH 2/7] Update stage 0 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 9e385ec2d5c5..3b14a8fc73b9 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-preview.6.20310.4", + "dotnet": "5.0.100-preview.8.20358.5", "runtimes": { "dotnet": [ "$(MicrosoftNETCoreAppRuntimePackageVersion)" From 8face8499a3b444aa3f5de227ffc3ace98c01ce3 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Thu, 9 Jul 2020 00:55:16 -0700 Subject: [PATCH 3/7] Update global.json --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 3b14a8fc73b9..d2bddf0631cc 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-preview.8.20358.5", + "dotnet": "5.0.100-preview.8.20351.5", "runtimes": { "dotnet": [ "$(MicrosoftNETCoreAppRuntimePackageVersion)" From e0ff7d63d5e8f57b1b4a076680ea19fce3d32935 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Thu, 9 Jul 2020 14:51:35 +0000 Subject: [PATCH 4/7] Update dependencies from https://github.com/dotnet/windowsdesktop build 20200708.1 Microsoft.WindowsDesktop.App From Version 5.0.0-preview.8.20352.5 -> To Version 5.0.0-preview.8.20358.1 Dependency coherency updates Microsoft.NET.Sdk.WindowsDesktop From Version 5.0.0-preview.8.20352.4 -> To Version 5.0.0-preview.8.20358.1 (parent: Microsoft.WindowsDesktop.App --- eng/Version.Details.xml | 8 ++++---- eng/Versions.props | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 80b7cde0d9fa..4fb0374bb9ba 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -85,13 +85,13 @@ https://github.com/dotnet/runtime 3155ca2dfa20e11949f24e439b54ba1816be3c22 - + https://github.com/dotnet/windowsdesktop - 130adb291e6cc6efa8ab14989f5b2527adedac2b + 47d20bf0c3dd54f84e678c987db33c7ac95bb2f6 - + https://github.com/dotnet/wpf - 96b36ed9cb7b41e127c94ca445ac4b4e46789999 + e36c6981d99317ffdfe0bcc9f1f264f59a29793d https://github.com/dotnet/aspnetcore diff --git a/eng/Versions.props b/eng/Versions.props index b55038cabc98..0444395b21ac 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -127,11 +127,11 @@ - 5.0.0-preview.8.20357.5 + 5.0.0-preview.8.20358.1 - 5.0.0-preview.8.20357.4 + 5.0.0-preview.8.20358.1 From a0c579502a30b1c6a16c679471a95b5d8c017345 Mon Sep 17 00:00:00 2001 From: William Li Date: Fri, 10 Jul 2020 09:48:17 -0700 Subject: [PATCH 5/7] Remove stop gap property No that Windows destkop change is fully flowed --- .../Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props | 2 +- .../Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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. - + From 7dceab297b56042aef9df1cee5052c8b2ed50ed7 Mon Sep 17 00:00:00 2001 From: William Li Date: Thu, 18 Jun 2020 16:34:54 -0700 Subject: [PATCH 6/7] Add test for Import windows props and targets --- ...venWeWantToRequireWindowsForDesktopApps.cs | 127 ++++++++++++++---- 1 file changed, 101 insertions(+), 26 deletions(-) diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs index fb7b109679f0..ba57f7f549d5 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs @@ -154,6 +154,93 @@ 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"); + + var asset = _testAssetsManager.CreateTestProject(testProject); + + var command = new BuildCommand(Log, Path.Combine(asset.Path, ProjectName)); + + command + .Execute() + .Should() + .Pass(); + } + private TestAsset CreateWindowsDesktopSdkTestAsset(string projectName, string uiFrameworkProperty) { const string tfm = "netcoreapp3.0"; @@ -189,34 +276,22 @@ 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 - - var asset = _testAssetsManager.CreateTestProject(testProject); + private readonly string _fileUseWindowsType = @" +using System.Windows; - var getValuesCommand = new GetValuesCommand(asset, "OutputType"); - getValuesCommand - .Execute() - .Should() - .Pass(); +namespace wpf +{ + public partial class App : Application + { + } - var values = getValuesCommand.GetValues(); - values.Count.Should().Be(1); - values.First().Should().Be(expectedOutputType); + class Program + { + static void Main(string[] args) + { } } } +"; + } +} From 71072ff439004dc1b27f618deef1472f1aec3591 Mon Sep 17 00:00:00 2001 From: William Li Date: Fri, 10 Jul 2020 14:48:25 -0700 Subject: [PATCH 7/7] Add for CSWinrt --- ...venWeWantToRequireWindowsForDesktopApps.cs | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs index ba57f7f549d5..a5fef6f64cbd 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs @@ -230,6 +230,7 @@ public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_without_Projec testProject.SourceFiles.Add("App.xaml.cs", _fileUseWindowsType); testProject.AdditionalProperties.Add("UseWPF", "true"); + testProject.AdditionalProperties.Add("TargetPlatformIdentifier", "Windows"); var asset = _testAssetsManager.CreateTestProject(testProject); @@ -241,6 +242,53 @@ public void It_builds_on_windows_with_the_windows_desktop_sdk_5_0_without_Projec .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"; @@ -292,6 +340,23 @@ static void Main(string[] args) } } } +"; + + 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""]); + } + } +} "; } }