Skip to content

Commit

Permalink
Add CsWinRT projection producing project for deployment API (#4949)
Browse files Browse the repository at this point in the history
## Change
Produce a CsWinRT projection for Microsoft.Management.Deployment.
Move to CsWinRT 2.1.6 across the solution.
  • Loading branch information
JohnMcPMS authored Nov 18, 2024
1 parent ff86443 commit 5645e0c
Show file tree
Hide file tree
Showing 16 changed files with 327 additions and 246 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ AMap
Amd
amrutha
ansistring
Aot
APARTMENTTHREADED
apfn
apicontract
Expand Down
428 changes: 227 additions & 201 deletions src/AppInstallerCLI.sln

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
<DocumentationFile>$(OutDir)\AppInstallerCLIE2ETests.xml</DocumentationFile>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -30,7 +29,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Msix.Utils" Version="2.1.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
<SelfContained>true</SelfContained>
<RuntimeIdentifiers>win10-x64;win10-x86;win10-arm;win10-arm64</RuntimeIdentifiers>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Platform)' == 'x64' ">
Expand All @@ -34,7 +33,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<CsWinRTEnableLogging>true</CsWinRTEnableLogging>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand All @@ -43,7 +42,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.8" GeneratePathProperty="true">
<ExcludeAssets>contentFiles</ExcludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<Nullable>enable</Nullable>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -28,7 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
<RuntimeIdentifiers>win10-x64;win10-x86;win10-arm;win10-arm64</RuntimeIdentifiers>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand All @@ -24,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-windows10.0.22000.0</TargetFrameworks>
<Platform>AnyCpu</Platform>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IsAotCompatible>true</IsAotCompatible>
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
<!--
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.53</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup>
<CsWinRTIncludes>Microsoft.Management.Deployment</CsWinRTIncludes>
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
<CsWinRTWindowsMetadata>10.0.22000.0</CsWinRTWindowsMetadata>
<!-- Ensure Support for Windows 10, Version 1809 -->
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>

<PropertyGroup>
<!-- Workaround for MSB3271 error on processor architecture mismatch -->
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.Management.Deployment\Microsoft.Management.Deployment.vcxproj">
<OutputItemType>Content</OutputItemType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ReferenceOutputAssembly>True</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
<OutputType>Library</OutputType>
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
</ItemGroup>

<!-- CsWinRT properties -->
Expand Down
13 changes: 12 additions & 1 deletion src/PowerShell/CommonFiles/WinGetAssemblyLoadContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// <copyright file="WinGetAssemblyLoadContext.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand Down Expand Up @@ -81,6 +81,17 @@ internal static Assembly ResolvingHandler(AssemblyLoadContext context, AssemblyN
return null;
}

/// <summary>
/// Handler to resolve unmanaged assemblies.
/// </summary>
/// <param name="assembly">Assembly initiating the unmanaged load.</param>
/// <param name="unmanagedDllName">Unmanaged dll name.</param>
/// <returns>The assembly ptr, zero if not in our assembly location.</returns>
internal static IntPtr ResolvingUnmanagedDllHandler(Assembly assembly, string unmanagedDllName)
{
return WinGetAcl.LoadUnmanagedDll(unmanagedDllName);
}

/// <inheritdoc/>
protected override Assembly Load(AssemblyName assemblyName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DesktopFramework>net48</DesktopFramework>
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<CsWinRTCcwLookupTableGeneratorEnabled>false</CsWinRTCcwLookupTableGeneratorEnabled>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -57,7 +57,7 @@

<!-- This project doesn't reference it directly, but if I don't add it here it will fail with NETSDK1130 *.winmd cannot be referenced. -->
<ItemGroup Condition="'$(TargetFramework)' == '$(CoreFramework)'">
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DesktopFramework>net48</DesktopFramework>
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<CsWinRTCcwLookupTableGeneratorEnabled>false</CsWinRTCcwLookupTableGeneratorEnabled>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -54,7 +54,7 @@
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" Condition="'$(TargetFramework)' == '$(DesktopFramework)'" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" Condition="'$(TargetFramework)' == '$(CoreFramework)'" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" Condition="'$(TargetFramework)' == '$(CoreFramework)'" />
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22000.196" PrivateAssets="all" Condition="'$(TargetFramework)' == '$(DesktopFramework)'" />
<PackageReference Include="System.Net.Http" Version="4.3.4" Condition="'$(TargetFramework)' == '$(DesktopFramework)'" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<BuildOutputDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</BuildOutputDirectory>
<RootNamespace>Microsoft.WinGet.Configuration</RootNamespace>
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<CsWinRTCcwLookupTableGeneratorEnabled>false</CsWinRTCcwLookupTableGeneratorEnabled>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down Expand Up @@ -48,7 +48,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// <copyright file="ModuleInit.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand Down Expand Up @@ -30,11 +30,13 @@ public void OnImport()
}

AssemblyLoadContext.Default.Resolving += WinGetAssemblyLoadContext.ResolvingHandler;
AssemblyLoadContext.Default.ResolvingUnmanagedDll += WinGetAssemblyLoadContext.ResolvingUnmanagedDllHandler;
}

/// <inheritdoc/>
public void OnRemove(PSModuleInfo module)
{
AssemblyLoadContext.Default.ResolvingUnmanagedDll -= WinGetAssemblyLoadContext.ResolvingUnmanagedDllHandler;
AssemblyLoadContext.Default.Resolving -= WinGetAssemblyLoadContext.ResolvingHandler;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<DocumentationFile>$(OutputPath)\$(MSBuildProjectName).xml</DocumentationFile>
<RuntimeIdentifier>win</RuntimeIdentifier>
<Configurations>Debug;Release;ReleaseStatic</Configurations>
<CsWinRTCcwLookupTableGeneratorEnabled>false</CsWinRTCcwLookupTableGeneratorEnabled>
<!--
Forcing this version to continue using an older CsWinRT release while issues are resolved.
!!! Remove this on the next Microsoft.Windows.CsWinRT package version update. !!!
!!! Remove or update this on the next Microsoft.Windows.CsWinRT package version update. !!!
-->
<WindowsSdkPackageVersion>10.0.22000.34</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.22000.52</WindowsSdkPackageVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down Expand Up @@ -48,7 +48,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 5 additions & 3 deletions src/PowerShell/scripts/Initialize-LocalWinGetModules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class WinGetModule
{
$this.Name = $n
$this.ModuleRoot = $m
$this.Output = "$o\$($this.Name)\"
$this.Output = Join-Path $o $this.Name
New-Item $this.Output -ItemType Directory -ErrorAction SilentlyContinue

if (Get-Module -Name $this.Name)
{
Expand All @@ -59,14 +60,15 @@ class WinGetModule

[void]PrepareScriptFiles()
{
Write-Verbose "Copying files: $($this.ModuleRoot) -> $($this.Output)"
Write-Verbose "Copying script files: $($this.ModuleRoot) -> $($this.Output)"
xcopy $this.ModuleRoot $this.Output /d /s /f /y
}

[void]PrepareBinaryFiles([string] $buildRoot, [string] $config)
{
Write-Verbose "Copying binary files: $buildRoot\AnyCpu\$config\PowerShell\$($this.Name)\* -> $($this.Output)"
$copyErrors = $null
Copy-Item "$buildRoot\AnyCpu\$config\PowerShell\$($this.Name)" $this.Output -Force -Recurse -ErrorVariable copyErrors -ErrorAction SilentlyContinue
Copy-Item "$buildRoot\AnyCpu\$config\PowerShell\$($this.Name)\*" $this.Output -Force -Recurse -ErrorVariable copyErrors -ErrorAction SilentlyContinue
$copyErrors | ForEach-Object { Write-Warning $_ }
}

Expand Down

0 comments on commit 5645e0c

Please sign in to comment.