Skip to content

Commit

Permalink
Modify build to include version in VSIX name (#1104)
Browse files Browse the repository at this point in the history
* Modify build to include version in VSIX name

Previously this was done separately in PowerShell in the build pipline.
However, the version properties are available during the build so we can create a VSIX with the expected name here - no need to rename later.
  • Loading branch information
duncanp-sonar authored Nov 20, 2019
1 parent 9a7b939 commit 635e010
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
13 changes: 9 additions & 4 deletions build/ChangeVersion.proj
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@
<Import Project="$(MSBuildProjectDirectory)\RegexTransform.tasks" />
<PropertyGroup>
<SolutionRoot>$(MSBuildProjectDirectory)\..</SolutionRoot>

<!-- Other calculated properties used only in RegEx transforms -->
<RegExAssemblyVersion>$(MainVersion)</RegExAssemblyVersion>
<RegExAssemblyFileVersion>$(FullVersion)</RegExAssemblyFileVersion>
<RegExAssemblyInformationalVersion>Version:$(FullVersion) Branch:$(BranchName) Sha1:$(Sha1) Configuration:$(BuildConfiguration)</RegExAssemblyInformationalVersion>
</PropertyGroup>

<ItemGroup>
<AssemblyVersion Include="$(SolutionRoot)\src\AssemblyInfo.Shared.cs">
<Find>(?&lt;=\[assembly\: AssemblyVersion\(")([^"]*)</Find>
<ReplaceWith>$(AssemblyVersion)</ReplaceWith>
<ReplaceWith>$(RegExAssemblyVersion)</ReplaceWith>
<ExpectedMatchCount>1</ExpectedMatchCount>
</AssemblyVersion>
<AssemblyFileVersion Include="$(SolutionRoot)\src\AssemblyInfo.Shared.cs">
<Find>(?&lt;=\[assembly\: AssemblyFileVersion\(")([^"]*)</Find>
<ReplaceWith>$(AssemblyFileVersion)</ReplaceWith>
<ReplaceWith>$(RegExAssemblyFileVersion)</ReplaceWith>
<ExpectedMatchCount>1</ExpectedMatchCount>
</AssemblyFileVersion>
<AssemblyInformationalVersion Include="$(SolutionRoot)\src\AssemblyInfo.Shared.cs">
<Find>(?&lt;=\[assembly\: AssemblyInformationalVersion\(")([^"]*)</Find>
<ReplaceWith>$(AssemblyInformationalVersion)</ReplaceWith>
<ReplaceWith>$(RegExAssemblyInformationalVersion)</ReplaceWith>
<ExpectedMatchCount>1</ExpectedMatchCount>
</AssemblyInformationalVersion>

Expand All @@ -31,7 +36,7 @@

<VsPackageVersion Include="$(SolutionRoot)\src\Integration.Vsix\SonarLintIntegrationPackage.cs">
<Find>(?&lt;=\[InstalledProductRegistration\("#110", "#112", ")([^"]*)</Find>
<ReplaceWith>$(AssemblyFileVersion)</ReplaceWith>
<ReplaceWith>$(RegExAssemblyFileVersion)</ReplaceWith>
<ExpectedMatchCount>1</ExpectedMatchCount>
</VsPackageVersion>
</ItemGroup>
Expand Down
12 changes: 5 additions & 7 deletions build/Version.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Manually set the three-part main version and check in the changed file.
The other build properties (e.g. Sha1) will be set by the CI build when
The other required build properties (e.g. Sha1) will be set by the CI build when
it builds ChangeVersion.proj. -->
<MainVersion>4.14.0</MainVersion>

<!-- Properties set by the CI build pipeline -->
<!-- Properties set by the CI build pipeline -->
<BuildNumber>0</BuildNumber>
<Sha1>not-set</Sha1>
<BranchName>not-set</BranchName>
<BuildConfiguration>not-set</BuildConfiguration>

<!-- Calculated properties -->
<FullVersion>$(MainVersion).$(BuildNumber)</FullVersion>
<AssemblyVersion>$(MainVersion)</AssemblyVersion>
<AssemblyFileVersion>$(FullVersion)</AssemblyFileVersion>
<AssemblyInformationalVersion>Version:$(FullVersion) Branch:$(BranchName) Sha1:$(Sha1) Configuration:$(BuildConfiguration)</AssemblyInformationalVersion>
<VsixVersion>$(FullVersion)</VsixVersion>
<VsixVersion>$(FullVersion)</VsixVersion>
</PropertyGroup>
</Project>
15 changes: 9 additions & 6 deletions src/Integration.Vsix/Integration.Vsix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- The VSSDK targets need to be imported after the Net.Sdk targets which means we have to import the
.NET.Sdk targets using Import rather than specifying it as the Sdk in the Project element. -->
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<!-- Executive summary:
* to build the VS2017 vsix, build from inside VS2017.
* to build the VS2019 vsix, build from inside VS2019.
Expand Down Expand Up @@ -36,6 +36,8 @@
To achieve this, this project conditionally imports different VSIX manifests based on the version of VS being
used to build the project/solution.
-->

<Import Project="..\..\build\version.props" />

<PropertyGroup>
<!-- Hack to prevent VS2017 from automatically attempting to upgrade the project -->
Expand All @@ -57,7 +59,8 @@
<ProjectGuid>{FF2AD819-28F4-493A-8E9B-1D3F16BD4689}</ProjectGuid>
<RootNamespace>SonarLint.VisualStudio.Integration.Vsix</RootNamespace>
<AssemblyName>SonarLint.$(VersionSpecificSuffix)</AssemblyName>

<TargetVsixContainerName>SonarLint.VSIX-$(VsixVersion)-$(VersionSpecificSuffix).vsix</TargetVsixContainerName>

<GeneratePkgDefFile>true</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
Expand Down Expand Up @@ -298,12 +301,12 @@
<BinariesFolder>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\..\binaries\))</BinariesFolder>
</PropertyGroup>
<ItemGroup>
<VSIXesToSign Include="$(BinariesFolder)$(AssemblyName).vsix" />
<VSIXesToSign Include="$(BinariesFolder)$(TargetVsixContainerName)" />
</ItemGroup>

<Target Name="CopyVsixToBinariesAndSign" AfterTargets="Build" Inputs="$(TargetDir)$(AssemblyName).vsix" Outputs="$(BinariesFolder)$(AssemblyName).vsix">
<Message Importance="high" Text="Copying vsix from $(TargetDir)$(AssemblyName).vsix to $(BinariesFolder)$(AssemblyName).vsix" />
<Copy OverwriteReadOnlyFiles="true" SourceFiles="$(TargetDir)$(AssemblyName).vsix" DestinationFiles="$(BinariesFolder)$(AssemblyName).vsix" />
<Target Name="CopyVsixToBinariesAndSign" AfterTargets="Build" Inputs="$(TargetDir)$(TargetVsixContainerName)" Outputs="$(BinariesFolder)$(TargetVsixContainerName)">
<Message Importance="high" Text="Copying vsix from $(TargetDir)$(TargetVsixContainerName) to $(BinariesFolder)$(TargetVsixContainerName)" />
<Copy OverwriteReadOnlyFiles="true" SourceFiles="$(TargetDir)$(TargetVsixContainerName)" DestinationFiles="$(BinariesFolder)$(TargetVsixContainerName)" />

<CallTarget Targets="SignVsixesIfPfxSupplied" />
</Target>
Expand Down

0 comments on commit 635e010

Please sign in to comment.