Skip to content

Commit

Permalink
Use a forced 32-bit version of the tool when PlatformTarget is x86
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLambrou committed Feb 2, 2017
1 parent 5d9fb17 commit 100328b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
39 changes: 38 additions & 1 deletion .build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ $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)

Write-Host "## $Message ##" -ForegroundColor Magenta
}


# Environment-specific configuration should happen here (and only here!)
task Init {
Write-Info 'Establishing build properties'
Expand Down Expand Up @@ -71,6 +73,7 @@ function Get-BranchName {
return 'master'
}


# Clean task, deletes all build output folders.
task Clean {
Write-Info 'Cleaning build output'
Expand All @@ -81,20 +84,23 @@ task Clean {
}
}


# RestorePackages task, restores all the NuGet packages.
task RestorePackages {
Write-Info "Restoring NuGet packages for solution $SolutionPath"

& $NuGetPath @('restore', $SolutionPath)
}


# UpdateAssemblyInfo task, updates the AssemblyVersion, AssemblyFileVersion and AssemblyInformationlVersion attributes in the source code.
task UpdateAssemblyInfo Init, {
Write-Info 'Updating assembly information'

"$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"
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
2 changes: 1 addition & 1 deletion XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<copyright>Copyright 2014-2016 Red Gate Software Ltd.</copyright>
<tags>PowerShell help xmldoc</tags>
<developmentDependency>true</developmentDependency>
<releaseNotes>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.
<releaseNotes>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.

Expand Down
8 changes: 6 additions & 2 deletions XmlDoc2CmdletDoc/XmlDoc2CmdletDoc.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
<XmlDoc2CmdletDocStrict>true</XmlDoc2CmdletDocStrict>
-->
<XmlDoc2CmdletDocStrict Condition="'$(XmlDoc2CmdletDocStrict)' == ''">false</XmlDoc2CmdletDocStrict>

<!-- Determine which platform version of XmlDoc2CmdletDoc.exe to use. -->
<XmlDocExeName Condition="'$(PlatformTarget)' == 'x86'">XmlDoc2CmdletDoc32.exe</XmlDocExeName>
<XmlDocExeName Condition="'$(XmlDocExeName)' == ''">XmlDoc2CmdletDoc.exe</XmlDocExeName>
</PropertyGroup>
<Target Name="XmlDoc2CmdletDoc"
BeforeTargets="PostBuildEvent"
Inputs="$(TargetPath)"
Outputs="$(TargetPath)-Help.xml">
<Exec Condition="'$(XmlDoc2CmdletDocStrict)' == 'false'"
Command='"$(MSBuildThisFileDirectory)..\tools\XmlDoc2CmdletDoc.exe" "$(TargetPath)"' />
Command='"$(MSBuildThisFileDirectory)..\tools\$(XmlDocExeName)" "$(TargetPath)"' />
<Exec Condition="'$(XmlDoc2CmdletDocStrict)' != 'false'"
Command='"$(MSBuildThisFileDirectory)..\tools\XmlDoc2CmdletDoc.exe" -strict "$(TargetPath)"' />
Command='"$(MSBuildThisFileDirectory)..\tools\$(XmlDocExeName)" -strict "$(TargetPath)"' />
</Target>
</Project>
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 100328b

Please sign in to comment.