ProjectReunion/MakeMsix.targets

87 строки
5.9 KiB
Plaintext
Исходник Обычный вид История

Generate cert (#1986) * Update DevCheck to generate MSTest.pfx/.cer * Refactor temp handling. Add .user dir * Change cert handling to use .user\* and direct certificate handler via Powershell's PKI module. Buh-bye all references to MSTest.* and certutil * Add -Remove-DevTestCert and -Remove-DevTestPfx * Change all temp\MSTest.pfx to .user\winappsdk.certificate.test.pfx * Added -CertPasswordFile, -CertPasswordUser, -RemoveAll. Save password as plaintext to .pwd file for later use * Update makemsix.cmd to pass along the .pwd content needed to use the (now password protected) .pfx * Update MSTest references * Start of changing NMAKEfiles to MSBuild * Add new file * MakeMsix.targets works! Rewrote DDLM.msix to work it out, when running a specific project (e.g. 'msbuild /bl /p:Configuration=Debug,Platform=x64 /t:Build test\DynamicDependency\data\DynamicDependencyLifetimeManager.Msix\DynamicDependencyLifetimeManager.Msix.vcxproj'). Now to verify it works when building the solution, moving MakeMsix.targets out to root\build and propogating this to the other makemsix projects * 'msbuild foo.vcxproj' works but 'msbuild bar.sln' fails due to 'C:\source\repos\windowsappsdk\test\DynamicDependency\data\DynamicDependencyLifetimeManager.Msix\DynamicDependencyLifetimeManager.Msix.vcxproj error MSB4057: The target GetProjectInfoForReference does not exist in the project. [C:\source\repos\windowsappsdk\' Seems GetPRojectInfoForReference is referenced by 'C:\ProgramFiles (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets' and Microsoft.Makefile.targets, we don't fit either but they're required to resolve '<ProjectReference...'? Is it possible to move the ProjectReference dependency to the .sln? Or make this work without trying to make a full blown C++ or NMake project? Time to ping some VS/MSBuild experts... * Tweaked the vcxproj to successfully create .msix via MakeMSIX! * Moved MakeMSIX.targets to the root (with other build files) * It works! Got the test projects building with the .pfx and .pwd * Rewiring test projects to use MakeMsix.targets instead of NMake * Yet more MakeMsix fixup * Fixed the package name * Added dummy Clean command (for now) * Fixed Deployment's test package where source files get put to different subdir+filename inside the msix * Fix DevCheck Start-Service to gracefully degrade if not running as admin * DeploymentTests were missing a build order dependency on BootstrapDLL project * Updated DevCheck generated cert to have 12-month lifespan (like current one) * Move Framework.* projects from makemsix.cmd to MakeMSIX.targets * Delete makemsix.cmd (obsolete) * Updated test projects to use static manifests instead of generated from a template (unnecessary complexity) * Deleted obsolete MakeAppxManifestFromTemplate.* * Removed obsolete manifest/template handling. Removed printfery debugging * Minor syntax cleanup. Fixed appxmanifest overly aggressive copy/paste human error <sheepish grin>. Fixed publish-header delete-custom-build-step human error * Fixup Math framework header publishing (due to bad merge due to the age of this change and other work in other branches that hit main. Grrr) * Deleted obsolete files * Replaced SolutionDir with RepoRoot * Rewrote installer's testpackage creation project to use MakeMSIX * Fixed naming inconsistencies * Addressed some issues. More to come * Fixed Get-UserPath emitting New-Item result to the output stream thus when creating the .user directory return $user returned System.Object[] with 2 objects in the stream (filename twice). Well, that was fun * Fix bad merge * Added Clean support to MakeMSIX. Cleanup up some internals including dependencies. MakeMsixOutputFilename is no longer optional and inferred; it must be defined by a project before import'ing makemsix.targets * Optimized load-test-cert-password to a global done once instead of per import rof makemsix.targets * Updated projects to use the common RepoTestCertificate* * Removed obsolete and redundant <Error> check * Added file-existence check before readng file. Added error check at start of project to flag missing-devcheck-artifacts early rather than late * Test WTH is going on * Remove debugging printfery. NOTE: Separate Jobs in a pipeline (will? may?) run in parallel on different machines. Until build-mrt.yml is merged into WindowsAppSDK-BuildProject-Steps.yml any common setup (or cleanup) needs to be done in both. Also, it means MRTCore *cannot* use any APIs in WindowsAppRuntime.sln because they're technically peers * Add DevCheck support to RunTestsInHelix job
2022-01-26 09:41:38 +03:00
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Sign packages by default. Set MakeMsixSigned=false to not sign created packages -->
<PropertyGroup>
<MakeMsixSigned Condition="'$(MakeMsixSigned)' == ''">true</MakeMsixSigned>
</PropertyGroup>
<!-- Clean artifacts from the MakeMSIX target -->
<Target Name="CleanMakeMSIX" AfterTargets="AfterClean">
<Error Condition="'$(MakeMsixOutputFilename)' == ''" Text="MakeMsixOutputFilename property is not defined" />
<PropertyGroup>
<_MakeMsix_WorkDir>$(OutDir)msix</_MakeMsix_WorkDir>
</PropertyGroup>
<RemoveDir Directories="$(_MakeMsix_WorkDir)" Condition="Exists('$(_MakeMsix_WorkDir)')" />
<Message Text="Cleaning $(OutDir)$(MakeMsixOutputFilename)" Importance="low"/>
<Delete Files="$(OutDir)$(MakeMsixOutputFilename)"/>
</Target>
<!-- Create an MSIX package and optionally sign it-->
<Target Name="MakeMSIX"
Inputs="@(MakeMsixInputs);@(MakeMsixInputsWithLocations);@(MakeMsixInputAssets)"
Outputs="$(OutDir)$(MakeMsixOutputFilename)"
AfterTargets="AfterBuild">
<Error Condition="'$(MakeMsixOutputFilename)' == ''" Text="MakeMsixOutputFilename property is not defined" />
<!-- Initial state diagnostics -->
<Message Text="MakeMSIX Pre: MSBuildProjectName=$(MSBuildProjectName)" Importance="low" />
<Message Text="MakeMSIX Pre: ProjectName=$(ProjectName)" Importance="low" />
<Message Text="MakeMSIX Pre: TargetName=$(TargetName)" Importance="low" />
<Message Text="MakeMSIX Pre: MakeMsixInputs=@(MakeMsixInputs)" Importance="low" />
<Message Text="MakeMSIX Pre: MakeMsixInputsWithLocations=@(MakeMsixInputsWithLocations)" Importance="low" />
<Message Text="MakeMSIX Pre: MakeMsixInputAssets=@(MakeMsixInputAssets)" Importance="low" />
<Message Text="MakeMSIX Pre: MakeMsixOutputFilename=$(MakeMsixOutputFilename)" Importance="low" />
<!-- Ensure MakeMsixOutputFilename is defined (defining it here if necessary, as per Microsoft.Cpp.Default.props line ~189) -->
<PropertyGroup>
<MakeMsixOutputFilename Condition="'$(MakeMsixOutputFilename)' == ''">$(ProjectName).msix</MakeMsixOutputFilename>
</PropertyGroup>
<Message Text="MakeMSIX: TargetName=$(MakeMsixOutputFilename)" Importance="low" />
<Message Text="MakeMSIX: OutDir=$(OutDir)" Importance="low" />
<PropertyGroup>
<_MakeMsix_WorkDir>$(OutDir)msix</_MakeMsix_WorkDir>
<_MakeMsix_OutDir>$(OutDir)</_MakeMsix_OutDir>
<_MakeMsix_OutFilename>$(_MakeMsix_OutDir)$(MakeMsixOutputFilename)</_MakeMsix_OutFilename>
<MakeMsixOutputFilename>$(_MakeMsix_OutFilename)</MakeMsixOutputFilename>
<_MakeMsix_Executable>makeappx.exe</_MakeMsix_Executable>
<_MakeMsix_Parameters>/o /h SHA256</_MakeMsix_Parameters>
<_MakeMsixCommand>$(_MakeMsix_Executable) pack $(_MakeMsix_Parameters) $(_MakeMsix_Options) /d $(_MakeMsix_WorkDir) /p $(_MakeMsix_OutFilename)</_MakeMsixCommand>
</PropertyGroup>
<Message Text="MakeMSIX: _MakeMsix_WorkDir=$(_MakeMsix_WorkDir)" Importance="low" />
<Message Text="MakeMSIX: _MakeMsix_OutDir=$(_MakeMsix_OutDir)" Importance="low" />
<Message Text="MakeMSIX: _MakeMsix_OutFilename=$(_MakeMsix_OutFilename)" Importance="low" />
<MakeDir Directories="$(_MakeMsix_WorkDir)" Condition="!Exists('$(_MakeMsix_WorkDir)')" />
<Message Text="MakeMSIX: Copy @(MakeMsixInputs) to $(_MakeMsix_WorkDir)" Importance="low" />
<Copy SourceFiles="@(MakeMsixInputs)" DestinationFolder="$(_MakeMsix_WorkDir)" SkipUnchangedFiles="true" />
<Message Text="MakeMSIX: Copy @(MakeMsixInputsWithLocations) to @(MakeMsixInputsWithLocations->'$(_MakeMsix_WorkDir)\%(TargetFile)')" Importance="low" />
<Copy SourceFiles="@(MakeMsixInputsWithLocations)"
DestinationFiles="@(MakeMsixInputsWithLocations->'$(_MakeMsix_WorkDir)\%(TargetFile)')"
SkipUnchangedFiles="true" />
<Message Text="MakeMSIX: Copy @(MakeMsixInputAssets) to $(_MakeMsix_WorkDir)\Assets" Importance="low" Condition="'@(MakeMsixInputAssets)' != ''"/>
<MakeDir Directories="$(_MakeMsix_WorkDir)\Assets" Condition="'@(MakeMsixInputAssets)' != '' and !Exists('$(_MakeMsix_WorkDir)\Assets')" />
<Copy SourceFiles="@(MakeMsixInputAssets)" DestinationFolder="$(_MakeMsix_WorkDir)\Assets" SkipUnchangedFiles="true" Condition="'@(MakeMsixInputAssets)' != ''"/>
<Message Text="MakeMSIX: Command: $(_MakeMsixCommand)" Importance="normal" />
<Exec Command="$(_MakeMsixCommand)" />
<!-- Sign the MSIX -->
<Error Condition="('$(MakeMsixSigned)' == 'true') and !Exists('$(RepoTestCertificatePFX)')" Text="$(RepoTestCertificatePFX) not found. Run '$(RepoRoot)\DevCheck.cmd' to generate the test certificate." />
<Error Condition="('$(MakeMsixSigned)' == 'true') and !Exists('$(RepoTestCertificatePWD)')" Text="$(RepoTestCertificatePWD) not found. Run '$(RepoRoot)\DevCheck.cmd' to generate the test certificate." />
Generate cert (#1986) * Update DevCheck to generate MSTest.pfx/.cer * Refactor temp handling. Add .user dir * Change cert handling to use .user\* and direct certificate handler via Powershell's PKI module. Buh-bye all references to MSTest.* and certutil * Add -Remove-DevTestCert and -Remove-DevTestPfx * Change all temp\MSTest.pfx to .user\winappsdk.certificate.test.pfx * Added -CertPasswordFile, -CertPasswordUser, -RemoveAll. Save password as plaintext to .pwd file for later use * Update makemsix.cmd to pass along the .pwd content needed to use the (now password protected) .pfx * Update MSTest references * Start of changing NMAKEfiles to MSBuild * Add new file * MakeMsix.targets works! Rewrote DDLM.msix to work it out, when running a specific project (e.g. 'msbuild /bl /p:Configuration=Debug,Platform=x64 /t:Build test\DynamicDependency\data\DynamicDependencyLifetimeManager.Msix\DynamicDependencyLifetimeManager.Msix.vcxproj'). Now to verify it works when building the solution, moving MakeMsix.targets out to root\build and propogating this to the other makemsix projects * 'msbuild foo.vcxproj' works but 'msbuild bar.sln' fails due to 'C:\source\repos\windowsappsdk\test\DynamicDependency\data\DynamicDependencyLifetimeManager.Msix\DynamicDependencyLifetimeManager.Msix.vcxproj error MSB4057: The target GetProjectInfoForReference does not exist in the project. [C:\source\repos\windowsappsdk\' Seems GetPRojectInfoForReference is referenced by 'C:\ProgramFiles (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets' and Microsoft.Makefile.targets, we don't fit either but they're required to resolve '<ProjectReference...'? Is it possible to move the ProjectReference dependency to the .sln? Or make this work without trying to make a full blown C++ or NMake project? Time to ping some VS/MSBuild experts... * Tweaked the vcxproj to successfully create .msix via MakeMSIX! * Moved MakeMSIX.targets to the root (with other build files) * It works! Got the test projects building with the .pfx and .pwd * Rewiring test projects to use MakeMsix.targets instead of NMake * Yet more MakeMsix fixup * Fixed the package name * Added dummy Clean command (for now) * Fixed Deployment's test package where source files get put to different subdir+filename inside the msix * Fix DevCheck Start-Service to gracefully degrade if not running as admin * DeploymentTests were missing a build order dependency on BootstrapDLL project * Updated DevCheck generated cert to have 12-month lifespan (like current one) * Move Framework.* projects from makemsix.cmd to MakeMSIX.targets * Delete makemsix.cmd (obsolete) * Updated test projects to use static manifests instead of generated from a template (unnecessary complexity) * Deleted obsolete MakeAppxManifestFromTemplate.* * Removed obsolete manifest/template handling. Removed printfery debugging * Minor syntax cleanup. Fixed appxmanifest overly aggressive copy/paste human error <sheepish grin>. Fixed publish-header delete-custom-build-step human error * Fixup Math framework header publishing (due to bad merge due to the age of this change and other work in other branches that hit main. Grrr) * Deleted obsolete files * Replaced SolutionDir with RepoRoot * Rewrote installer's testpackage creation project to use MakeMSIX * Fixed naming inconsistencies * Addressed some issues. More to come * Fixed Get-UserPath emitting New-Item result to the output stream thus when creating the .user directory return $user returned System.Object[] with 2 objects in the stream (filename twice). Well, that was fun * Fix bad merge * Added Clean support to MakeMSIX. Cleanup up some internals including dependencies. MakeMsixOutputFilename is no longer optional and inferred; it must be defined by a project before import'ing makemsix.targets * Optimized load-test-cert-password to a global done once instead of per import rof makemsix.targets * Updated projects to use the common RepoTestCertificate* * Removed obsolete and redundant <Error> check * Added file-existence check before readng file. Added error check at start of project to flag missing-devcheck-artifacts early rather than late * Test WTH is going on * Remove debugging printfery. NOTE: Separate Jobs in a pipeline (will? may?) run in parallel on different machines. Until build-mrt.yml is merged into WindowsAppSDK-BuildProject-Steps.yml any common setup (or cleanup) needs to be done in both. Also, it means MRTCore *cannot* use any APIs in WindowsAppRuntime.sln because they're technically peers * Add DevCheck support to RunTestsInHelix job
2022-01-26 09:41:38 +03:00
<PropertyGroup Condition="'$(MakeMsixSigned)' == 'true'">
<_SignMsix_Executable>signtool.exe</_SignMsix_Executable>
<_SignMsix_Parameters>/fd SHA256</_SignMsix_Parameters>
<_SignMsixCommand>$(_SignMsix_Executable) sign $(_SignMsix_Parameters) $(_SignMsix_Options) /f "$(RepoTestCertificatePFX)" /p "$(RepoTestCertificatePassword)" "$(_MakeMsix_OutFilename)"</_SignMsixCommand>
<_SignMsixCommand_Redacted>$(_SignMsix_Executable) sign $(_SignMsix_Parameters) $(_SignMsix_Options) /f "$(RepoTestCertificatePFX)" /p "$(RepoTestCertificatePasswordRedacted)" "$(_MakeMsix_OutFilename)"</_SignMsixCommand_Redacted>
</PropertyGroup>
<Message Text="MakeMSIX: Sign: $(_SignMsixCommand_Redacted)" Importance="normal" Condition="'$(MakeMsixSigned)' == 'true'" />
<Exec Command="$(_SignMsixCommand)" Condition="'$(MakeMsixSigned)' == 'true'"/>
</Target>
</Project>