Skip to content

Commit 9f083d6

Browse files
committed
Manually control assembly version
Switched the build process over so that MSBuild no longer auto-generates the assembly version. Instead, we pass it to MSBuild with the `Version` parameter.
1 parent 8bcdc8d commit 9f083d6

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

.github/workflows/build-solution.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
type: string
1414

1515
version:
16-
description: 'Version number to refer to this build and its assets, in `v.major.minor.build`.'
16+
description: 'Version number to refer to this build and its assets, in the form `major.minor.build`.'
1717
required: true
1818
type: string
1919
workflow_call:
@@ -24,7 +24,7 @@ on:
2424
type: string
2525

2626
version:
27-
description: 'Version number to refer to this build and its assets, in `v.major.minor.build`.'
27+
description: 'Version number to refer to this build and its assets, in the form `major.minor.build`.'
2828
required: true
2929
type: string
3030

@@ -46,8 +46,6 @@ jobs:
4646
strategy:
4747
matrix:
4848
os: [windows-latest]
49-
outputs:
50-
asmVersion: ${{ steps.getversion.outputs.version }}
5149
steps:
5250
# Build output goes in this runner's temp directory
5351
- name: Get output directory
@@ -65,19 +63,16 @@ jobs:
6563

6664
# msbuild cannot handle .vdproj Installer projects, so only build debug for now.
6765
- name: Build solution
68-
run: msbuild $env:SLN_DIR\$env:SLN_FILE -nologo -property:Configuration=${{ inputs.buildMode }} -property:OutDir=${{ env.OUTPUT }}
69-
70-
# For now, let msbuild continue autogenerating assembly versions and base everything off of that.
71-
- name: Get AssemblyVersion generated by msbuild
72-
id: getversion
73-
uses: berglie/assembly-version/get@v1
74-
with:
75-
directory: ${{ env.OUTPUT }}
66+
run: >
67+
msbuild $env:SLN_DIR\$env:SLN_FILE -nologo
68+
-property:Configuration=${{ inputs.buildMode }}
69+
-property:OutDir=${{ env.OUTPUT }}
70+
-property:Version=${{ inputs.version }}
7671
7772
- name: Upload Artifact
7873
uses: actions/upload-artifact@v3
7974
with:
80-
name: ${{ format('winnut-client-{0}-{1}', inputs.buildMode, vars.GITHUB_WORKFLOW_SHA) }}
75+
name: ${{ format('winnut-client-{0}-{1}', inputs.buildMode, inputs.version) }}
8176
if-no-files-found: error
8277
path: ${{ env.OUTPUT }}
8378

WinNUT_V2/SharedAssemblyInfo.vb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,4 @@ Imports System.Reflection
2020
<Assembly: AssemblyProduct("WinNUT Client")>
2121
<Assembly: AssemblyCopyright("NUTDotNet contributors © 2019-2022")>
2222
<Assembly: AssemblyTrademark("https://github.com/nutdotnet/WinNUT-Client")>
23-
24-
' Les informations de version pour un assembly se composent des quatre valeurs suivantes :
25-
'
26-
' Version principale
27-
' Version secondaire
28-
' Numéro de build
29-
' Révision
30-
'
31-
' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
32-
' en utilisant '*', comme indiqué ci-dessous :
33-
' <Assembly: AssemblyVersion("1.0.*")>
34-
35-
<Assembly: AssemblyVersion("2.2.*")>
3623
<Assembly: NeutralResourcesLanguage("en-US")>

WinNUT_V2/WinNUT-Client/WinNUT-client.vbproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<MapFileExtensions>true</MapFileExtensions>
2828
<ApplicationRevision>1</ApplicationRevision>
2929
<ApplicationVersion>2.2.0.%2a</ApplicationVersion>
30+
<Version Condition="'$(Version)' == ''">0.0.0.0</Version>
3031
<UseApplicationTrust>false</UseApplicationTrust>
3132
<PublishWizardCompleted>true</PublishWizardCompleted>
3233
<BootstrapperEnabled>true</BootstrapperEnabled>
@@ -44,6 +45,8 @@
4445
<DocumentationFile>WinNUT-Client.xml</DocumentationFile>
4546
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
4647
<Optimize>false</Optimize>
48+
<DefineConstants>
49+
</DefineConstants>
4750
</PropertyGroup>
4851
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4952
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -407,4 +410,16 @@
407410
<Target Name="MATPrerequisite" BeforeTargets="PrepareForBuild" Condition="!Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets')" Label="MultilingualAppToolkit">
408411
<Warning Text="$(MSBuildProjectFile) is Multilingual build enabled, but the Multilingual App Toolkit is unavailable during the build. If building with Visual Studio, please check to ensure that toolkit is properly installed." />
409412
</Target>
413+
<Target Name="BeforeBuild">
414+
<ItemGroup>
415+
<AssemblyAttributes Include="AssemblyVersion">
416+
<_Parameter1>$(Version)</_Parameter1>
417+
</AssemblyAttributes>
418+
</ItemGroup>
419+
<MakeDir Directories="$(IntermediateOutputPath)" />
420+
<WriteCodeFragment Language="VB" OutputFile="$(IntermediateOutputPath)Version.cs" AssemblyAttributes="@(AssemblyAttributes)" />
421+
<ItemGroup>
422+
<Compile Include="$(IntermediateOutputPath)Version.cs" />
423+
</ItemGroup>
424+
</Target>
410425
</Project>

0 commit comments

Comments
 (0)