Skip to content

Commit

Permalink
Add versioning function to MakeAppX.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
Grabacr07 committed Dec 12, 2016
1 parent fefae05 commit 70dea5f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
59 changes: 56 additions & 3 deletions packaging/MakeAppX.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
$target = 'Release (AppX)'
$bin = '..\source\SylphyHorn\bin'

$targetKeywords = '*.exe','*.dll','*.exe.config','*.txt','*.VisualElementsManifest.xml', '*.png', 'AppxManifest.xml'
$appxManifest = 'AppxManifest.xml'
$appxManifestSource = 'app.appxmanifest'
$versionSource = 'SylphyHorn.exe'

$targetKeywords = '*.exe','*.dll','*.exe.config','*.txt','*.VisualElementsManifest.xml', '*.png', $appxManifest
$ignoreKeyword = '*.vshost.*'

$appx = 'SylphyHorn.appx'
Expand Down Expand Up @@ -37,7 +41,13 @@
Get-ChildItem | where { $_.Name -eq $appx -or $_.Name -eq $appxBundle } | Remove-Item
Get-ChildItem | where Name -Like "_*" | Remove-Item

New-MappingFile -SourcePath $(Join-Path $bin $target) -Filename $appxMapping -Targets $targetKeywords -Exclude $ignoreKeyword
$source = Join-Path $bin $target -Resolve
$version = $(Get-ChildItem (Join-Path $source $versionSource)).VersionInfo.FileVersion

# replace version in appxmanifest with assembly version
$(Get-Content (Join-Path $source $appxManifestSource -Resolve)) -replace 'Version="0.0.0.0"', (' Version="{0}"' -f $version) | Out-File (Join-Path $source $appxManifest) -Encoding UTF8

New-MappingFile -SourcePath $source -Filename $appxMapping -Targets $targetKeywords -Exclude $ignoreKeyword

Start-SdkTool -SdkPath $win10Sdk -ToolName 'makeappx' -Arguments "pack /l /f $appxMapping /p $appx"
Start-SdkTool -SdkPath $win10Sdk -ToolName 'signtool' -Arguments "sign /f $storekey /fd SHA256 /v $appx"
Expand All @@ -50,7 +60,7 @@

New-MappingFile -SourcePath '.\' -Filename $appxBundleMapping -Targets $appx

Start-SdkTool -SdkPath $win10Sdk -ToolName 'makeappx' -Arguments "bundle /f $appxBundleMapping /p $appxBundle"
Start-SdkTool -SdkPath $win10Sdk -ToolName 'makeappx' -Arguments "bundle /f $appxBundleMapping /p $appxBundle /bv $version"
}
catch
{
Expand Down Expand Up @@ -117,6 +127,49 @@ function New-MappingFile
}
}

function hoge
{
[CmdletBinding()]
param
(
[parameter(
mandatory = 1,
position = 0,
ValueFromPipeline = 1,
ValueFromPipelineByPropertyName = 1)]
[string]
$SdkPath,

[parameter(
mandatory = 1,
position = 1,
ValueFromPipelineByPropertyName = 1)]
[string]
$ToolName,

[parameter(
mandatory = 1,
position = 2,
ValueFromPipelineByPropertyName = 1)]
[string]
$Arguments
)

begin
{
$exe = (Join-Path $SdkPath ($ToolName + '.exe'))
}

end
{
Write-Host $ToolName $Arguments
Write-Host '----------'
& $exe ($Arguments -split " ")
Write-Host ''
Write-Host ''
}
}

function Start-SdkTool
{
[CmdletBinding()]
Expand Down
2 changes: 1 addition & 1 deletion source/SylphyHorn/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyVersion("2.3.0.0")]
[assembly: ComVisible(false)]
4 changes: 2 additions & 2 deletions source/SylphyHorn/SylphyHorn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SylphyHorn.Core\SylphyHorn.Core.csproj">
Expand All @@ -325,7 +325,7 @@
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<None Include="AppxManifest.xml">
<None Include="app.appxmanifest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Identity Name="46846grabacr.net.SylphyHorn"
ProcessorArchitecture="x86"
Publisher="CN=33C1D2CA-4B3F-4CCA-8103-6D02939C6477"
Version="2.2.0.0" />
Version="0.0.0.0" />
<Properties>
<DisplayName>SylphyHorn</DisplayName>
<PublisherDisplayName>grabacr.net</PublisherDisplayName>
Expand Down

0 comments on commit 70dea5f

Please sign in to comment.