Skip to content

Commit

Permalink
Unify version specifying (#1439)
Browse files Browse the repository at this point in the history
* installer: extract version number into separate file and use it where possible

* MSIX: rename package to include version on CDPx

* installer: generate assembly info for FZ editor

* MSIX: inject correct version to appxmanifest
  • Loading branch information
yuyoyuppe authored and enricogior committed Mar 9, 2020
1 parent 6794afa commit 5d46c6a
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .pipelines/pipeline.user.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ build:
- from: 'installer\PowerToysSetup\x64\Release'
to: 'Build_Installer_Output'
include:
- 'PowerToysSetup.msi'
- 'PowerToysSetup-*.msi'
signing_options:
sign_inline: true # This does signing a soon as this command completes
# - !!buildcommand
Expand Down
10 changes: 10 additions & 0 deletions installer/MSIX/build_msix_cdpx.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
cd /D "%~dp0"

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 -winsdk=10.0.18362.0

powershell -file update_appxmanifest_version.ps1 || exit /b 1

call makeappx build /v /overwrite /f PackagingLayout.xml /id "PowerToys-x64" /op bin\ || exit /b 1

setlocal EnableDelayedExpansion
for /f "tokens=3delims=<>" %%i in ('findstr "<Version>" "..\Version.props"') do (
set MSIXVERSION=%%i
)
setlocal DisableDelayedExpansion
ren "bin\PowerToys-x64.msix" PowerToysSetup-%MSIXVERSION%-x64.msix
5 changes: 5 additions & 0 deletions installer/MSIX/update_appxmanifest_version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$version = ([xml](Get-Content ..\Version.props)).Project.PropertyGroup.Version

(Get-Content appxmanifest.xml) `
-replace '(Name="[\.\w]+"\sVersion=")([\d\.]+)"', -join('${1}', $version, '.0"') `
| Out-File -Encoding utf8 appxmanifest.xml
3 changes: 2 additions & 1 deletion installer/PowerToysSetup/PowerToysSetup.wixproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureNuGetPackageBuildImports" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\WiX.3.11.2\build\wix.props" Condition="Exists('..\packages\WiX.3.11.2\build\wix.props')" />
<Import Project="$(SolutionDir)Version.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>022a9d30-7c4f-416d-a9df-5ff2661cc0ad</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>PowerToysSetup</OutputName>
<OutputName>PowerToysSetup-$(Version)-$(Platform)</OutputName>
<OutputType>Package</OutputType>
<SuppressAclReset>True</SuppressAclReset>
<NuGetPackageImportStamp>
Expand Down
6 changes: 3 additions & 3 deletions installer/PowerToysSetup/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Product Id="*"
Name="PowerToys (Preview)"
Language="1033"
Version="0.15.2"
Version="$(var.Version)"
Manufacturer="Microsoft"
UpgradeCode="42B84BF7-5FBF-473B-9C8B-049DC16F7708">

Expand All @@ -18,9 +18,9 @@

<Upgrade Id="42B84BF7-5FBF-473B-9C8B-049DC16F7708">
<UpgradeVersion
Minimum="0.11.0" Maximum="0.14.1"
Minimum="0.11.0" Maximum="$(var.Version)"
Property="PREVIOUSVERSIONSINSTALLED"
IncludeMinimum="yes" IncludeMaximum="yes" />
IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>

<MediaTemplate EmbedCab="yes" />
Expand Down
7 changes: 7 additions & 0 deletions installer/Version.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>0.15.2</Version>
<DefineConstants>Version=$(Version);</DefineConstants>
</PropertyGroup>
</Project>
15 changes: 15 additions & 0 deletions src/common/common.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\installer\Version.props" />
<Target Name="GenerateVersionData" BeforeTargets="PrepareForBuild">
<ItemGroup>
<HeaderLines Include="#pragma once" />
<HeaderLines Include="#define VERSION_MAJOR $(Version.Split('.')[0])" />
<HeaderLines Include="#define VERSION_MINOR $(Version.Split('.')[1])" />
<HeaderLines Include="#define VERSION_REVISION $(Version.Split('.')[2])" />
</ItemGroup>
<WriteLinesToFile
File="Generated Files\version_gen.h"
Lines="@(HeaderLines)"
Overwrite="true"
Encoding="Unicode"
WriteOnlyWhenDifferent="true" />
</Target>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
Expand Down
20 changes: 9 additions & 11 deletions src/common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)

#define VERSION_MAJOR 0
#define VERSION_MINOR 15
#define VERSION_REVISION 2

#define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, 0
#define FILE_VERSION_STRING STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_REVISION) ".0"
#include "Generated Files\version_gen.h"

#define PRODUCT_VERSION FILE_VERSION
#define PRODUCT_VERSION_STRING FILE_VERSION_STRING
#define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, 0
#define FILE_VERSION_STRING \
STRINGIZE(VERSION_MAJOR) \
"." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_REVISION) ".0"
#define PRODUCT_VERSION FILE_VERSION
#define PRODUCT_VERSION_STRING FILE_VERSION_STRING
#define COMPANY_NAME "Microsoft Corporation"

#define COMPANY_NAME "Microsoft Corporation"
#define COPYRIGHT_NOTE "Copyright (C) 2019 Microsoft Corporation"

#define COPYRIGHT_NOTE "Copyright (C) 2019 Microsoft Corporation"
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="..\..\..\..\..\installer\Version.props" />
<!-- We don't have GenerateAssemblyInfo task until we use .net core, so we generate it with WriteLinesToFile -->
<PropertyGroup>
<AssemblyTitle>FancyZonesEditor</AssemblyTitle>
<AssemblyCompany>Microsoft Corp.</AssemblyCompany>
<AssemblyCopyright>Copyright (C) 2019 Microsoft Corp.</AssemblyCopyright>
</PropertyGroup>
<ItemGroup>
<AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cs"/>
</ItemGroup>
<Target Name="GenerateAssemblyInfo" BeforeTargets="PrepareForBuild">
<ItemGroup>
<HeaderLines Include="// Copyright (c) Microsoft Corporation" />
<HeaderLines Include="// The Microsoft Corporation licenses this file to you under the MIT license." />
<HeaderLines Include="// See the LICENSE file in the project root for more information." />

<HeaderLines Include="#pragma warning disable SA1516" />
<HeaderLines Include="using System.Reflection%3b" />
<HeaderLines Include="using System.Runtime.InteropServices%3b" />
<HeaderLines Include="using System.Windows%3b" />
<HeaderLines Include="[assembly: AssemblyTitle(&quot;$(AssemblyTitle)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyDescription(&quot;&quot;)]" />
<HeaderLines Include="[assembly: AssemblyConfiguration(&quot;&quot;)]" />
<HeaderLines Include="[assembly: AssemblyCompany(&quot;$(AssemblyCompany)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyCopyright(&quot;$(AssemblyCopyright)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyProduct(&quot;$(AssemblyTitle)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyTrademark(&quot;&quot;)]" />
<HeaderLines Include="[assembly: AssemblyCulture(&quot;&quot;)]" />
<HeaderLines Include="[assembly: ComVisible(false)]" />
<HeaderLines Include="[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]" />
<HeaderLines Include="[assembly: AssemblyVersion(&quot;$(Version).0&quot;)]" />
<HeaderLines Include="[assembly: AssemblyFileVersion(&quot;$(Version).0&quot;)]" />
</ItemGroup>

<WriteLinesToFile
File="Generated Files\AssemblyInfo.cs"
Lines="@(HeaderLines)"
Overwrite="true"
Encoding="Unicode"
WriteOnlyWhenDifferent="true" />
</Target>

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -163,7 +205,7 @@
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<Compile Include="Generated Files\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
Expand Down

This file was deleted.

0 comments on commit 5d46c6a

Please sign in to comment.