From 100328b258a72e2dd3daf5b4392f883f2e60aebe Mon Sep 17 00:00:00 2001 From: Chris Lambrou Date: Thu, 2 Feb 2017 23:34:24 +0000 Subject: [PATCH] Use a forced 32-bit version of the tool when PlatformTarget is x86 --- .build/build.ps1 | 39 ++++++++++++++++++++++- SolutionInfo.cs | 2 +- XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.nuspec | 2 +- XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.targets | 8 +++-- build.ps1 | 2 +- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/.build/build.ps1 b/.build/build.ps1 index 7393ac0..3227a02 100644 --- a/.build/build.ps1 +++ b/.build/build.ps1 @@ -13,6 +13,7 @@ $SolutionPath = "$RepositoryRoot\XmlDoc2CmdletDoc.sln" | Resolve-Path $NuGetPath = "$PsScriptRoot\nuget.exe" | Resolve-Path $DistPath = "$RepositoryRoot\dist" + # Helper function for clearer logging of each task. function Write-Info { param ([string] $Message) @@ -20,6 +21,7 @@ function Write-Info { Write-Host "## $Message ##" -ForegroundColor Magenta } + # Environment-specific configuration should happen here (and only here!) task Init { Write-Info 'Establishing build properties' @@ -71,6 +73,7 @@ function Get-BranchName { return 'master' } + # Clean task, deletes all build output folders. task Clean { Write-Info 'Cleaning build output' @@ -81,6 +84,7 @@ task Clean { } } + # RestorePackages task, restores all the NuGet packages. task RestorePackages { Write-Info "Restoring NuGet packages for solution $SolutionPath" @@ -88,6 +92,7 @@ task RestorePackages { & $NuGetPath @('restore', $SolutionPath) } + # UpdateAssemblyInfo task, updates the AssemblyVersion, AssemblyFileVersion and AssemblyInformationlVersion attributes in the source code. task UpdateAssemblyInfo Init, { Write-Info 'Updating assembly information' @@ -95,6 +100,7 @@ task UpdateAssemblyInfo Init, { "$RepositoryRoot\SolutionInfo.cs" | Resolve-Path | Update-AssemblyVersion -Version $Version -InformationalVersion $NuGetPackageVersion } + # Compile task, runs MSBuild to build the solution. task Compile UpdateAssemblyInfo, RestorePackages, { Write-Info "Compiling solution $SolutionPath" @@ -108,7 +114,38 @@ task Compile UpdateAssemblyInfo, RestorePackages, { } } -task Sign Compile, { + +# Create a forced 32-bit version of the tool. +task CorFlags Compile, { + Write-Info "Using CorFlags.exe to create a 32-bit forced version of XmlDoc2CmdletDoc.exe" + + copy -Force "$RepositoryRoot\XmlDoc2CmdletDoc\bin\$Configuration\XmlDoc2CmdletDoc.exe" "$RepositoryRoot\XmlDoc2CmdletDoc\bin\$Configuration\XmlDoc2CmdletDoc32.exe" + + $CorFlagsPath = Get-CorFlagsPath + Write-Host "CorFlagsPath = $CorFlagsPath" + $Parameters = @( + "$RepositoryRoot\XmlDoc2CmdletDoc\bin\$Configuration\XmlDoc2CmdletDoc32.exe" + '/32BITREQ+' + ) + + exec { + & $CorFlagsPath $Parameters + } +} + +function Get-CorFlagsPath { + $Files = "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows" ` + | Get-ChildItem -File -Recurse -Filter CorFlags.exe ` + | Sort-Object -Descending { $_.VersionInfo.ProductVersion } + if ($Files.Count -eq 0) { + throw 'Failed to locate CorFlags.exe' + } + return $Files[0].FullName +} + + +# Sign the files (note that this is signing, not strong-naming) +task Sign CorFlags, { if (-not $AssemblySigningEnabled) { Write-Info 'Skipping assembly signing' } else { diff --git a/SolutionInfo.cs b/SolutionInfo.cs index 82b4945..7c0ba84 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -20,4 +20,4 @@ // Instead, change the value defined in version-number.txt. [assembly: AssemblyVersion("0.2.7")] [assembly: AssemblyFileVersion("0.2.7")] -[assembly: AssemblyInformationalVersion("0.2.7-Fix64BitAssemblyLoad")] +[assembly: AssemblyInformationalVersion("0.2.7-Fix64Bit001")] diff --git a/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.nuspec b/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.nuspec index e3d9348..89ecddd 100644 --- a/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.nuspec +++ b/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.nuspec @@ -15,7 +15,7 @@ Copyright 2014-2016 Red Gate Software Ltd. PowerShell help xmldoc true - Version 0.2.7 - Fixed issue #31. Removed affinity for running as a 32-bit process, thus ensuring 64-bit target modules can be loaded. + Version 0.2.7 - Fixed issue #31. Use platform-specific versions of XmlDoc2CmdletDoc.exe Version 0.2.6 - Fixed issue #28. Ensure that help syntax is correctly displayed for parameterless cmdlets. diff --git a/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.targets b/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.targets index 7545358..81983f3 100644 --- a/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.targets +++ b/XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.targets @@ -8,14 +8,18 @@ true --> false + + + XmlDoc2CmdletDoc32.exe + XmlDoc2CmdletDoc.exe + Command='"$(MSBuildThisFileDirectory)..\tools\$(XmlDocExeName)" "$(TargetPath)"' /> + Command='"$(MSBuildThisFileDirectory)..\tools\$(XmlDocExeName)" -strict "$(TargetPath)"' /> \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index f44edb3..9b24cef 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,4 @@ # Initialises the build system (which declares three global build functions, build, clean and rebuild) then starts a build. # The real work of the build system is defined in .build\build.ps1 and .build\_init.ps1. & "$PsScriptRoot\.build\_init.ps1" -Build +Rebuild