Skip to content

Commit f1564ea

Browse files
authored
Add arm64 as a possible WinForms arch (dotnet#7457)
* Add arm64 as a possible WinForms arch * Add Winforms RT assets to shared and WindowsDesktop refs to ARM64 SDK * Add ARM WindowsDesktop tests
2 parents 0adcdc9 + 63ca195 commit f1564ea

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

src/redist/targets/GenerateBundledVersions.targets

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
<WindowsDesktop30RuntimePackRids Include="win-x64;win-x86" />
114114
<WindowsDesktop31RuntimePackRids Include="@(WindowsDesktop30RuntimePackRids)" />
115115
<WindowsDesktopRuntimePackRids Include="@(WindowsDesktop31RuntimePackRids)" />
116+
<!-- TODO: remove this once WPF is available on ARM64 and replace usage
117+
of this group for WindowsDesktopRuntimePackRids. -->
118+
<WindowsDesktopRuntimePackWinformsRids Include="@(WindowsDesktopRuntimePackRids);win-arm64" />
116119
</ItemGroup>
117120

118121
<!--
@@ -261,7 +264,7 @@ Copyright (c) .NET Foundation. All rights reserved.
261264
TargetingPackName="Microsoft.WindowsDesktop.App.Ref"
262265
TargetingPackVersion="$(MicrosoftWindowsDesktopAppRefPackageVersion)"
263266
RuntimePackNamePatterns="Microsoft.WindowsDesktop.App.Runtime.**RID**"
264-
RuntimePackRuntimeIdentifiers="@(WindowsDesktopRuntimePackRids, '%3B')"
267+
RuntimePackRuntimeIdentifiers="@(WindowsDesktopRuntimePackWinformsRids, '%3B')"
265268
IsWindowsOnly="true"
266269
Profile="WindowsForms"
267270
/>

src/redist/targets/GenerateLayout.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@
283283

284284
<PropertyGroup>
285285
<IncludeWpfAndWinForms Condition=" '$(IncludeWpfAndWinForms)' == '' AND '$(Architecture)' == 'arm'">false</IncludeWpfAndWinForms>
286-
<IncludeWpfAndWinForms Condition=" '$(IncludeWpfAndWinForms)' == '' AND '$(OS)' == 'Windows_NT' AND '$(Architecture)' != 'arm64' ">true</IncludeWpfAndWinForms>
286+
<IncludeWpfAndWinForms Condition=" '$(IncludeWpfAndWinForms)' == '' AND '$(OS)' == 'Windows_NT'">true</IncludeWpfAndWinForms>
287287
<IncludeWpfAndWinForms Condition=" '$(IncludeWpfAndWinForms)' == '' ">false</IncludeWpfAndWinForms>
288288
</PropertyGroup>
289289

test/EndToEnd/ProjectBuildTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System.IO;
5+
using System.Linq;
56
using System.Runtime.InteropServices;
67
using System.Xml.Linq;
78
using Microsoft.DotNet.TestFramework;
@@ -82,6 +83,51 @@ public void ItCanRunAnAppUsingTheWebSdk()
8283
.Should().Pass().And.HaveStdOutContaining("Hello World!");
8384
}
8485

86+
[WindowsOnlyFact]
87+
public void ItCanPublishArm64Winforms()
88+
{
89+
DirectoryInfo directory = TestAssets.CreateTestDirectory();
90+
string projectDirectory = directory.FullName;
91+
92+
string newArgs = "winforms --no-restore";
93+
new NewCommandShim()
94+
.WithWorkingDirectory(projectDirectory)
95+
.Execute(newArgs)
96+
.Should().Pass();
97+
98+
string publishArgs="-r win-arm64";
99+
new PublishCommand()
100+
.WithWorkingDirectory(projectDirectory)
101+
.Execute(publishArgs)
102+
.Should().Pass();
103+
104+
var selfContainedPublishDir = new DirectoryInfo(projectDirectory)
105+
.Sub("bin").Sub("Debug").GetDirectories().FirstOrDefault()
106+
.Sub("win-arm64").Sub("publish");
107+
108+
selfContainedPublishDir.Should().HaveFilesMatching("System.Windows.Forms.dll", SearchOption.TopDirectoryOnly);
109+
selfContainedPublishDir.Should().HaveFilesMatching($"{directory.Name}.dll", SearchOption.TopDirectoryOnly);
110+
}
111+
112+
[WindowsOnlyFact]
113+
public void ItCantPublishArm64Wpf()
114+
{
115+
DirectoryInfo directory = TestAssets.CreateTestDirectory();
116+
string projectDirectory = directory.FullName;
117+
118+
string newArgs = "wpf --no-restore";
119+
new NewCommandShim()
120+
.WithWorkingDirectory(projectDirectory)
121+
.Execute(newArgs)
122+
.Should().Pass();
123+
124+
string publishArgs="-r win-arm64";
125+
new PublishCommand()
126+
.WithWorkingDirectory(projectDirectory)
127+
.Execute(publishArgs)
128+
.Should().Fail();
129+
}
130+
85131
[Theory]
86132
[InlineData("console")]
87133
[InlineData("classlib")]

0 commit comments

Comments
 (0)