Skip to content

Instantly share code, notes, and snippets.

@cezarypiatek
Last active February 15, 2022 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cezarypiatek/42553a6364fb2ccc8a81dcea570fdde1 to your computer and use it in GitHub Desktop.
Save cezarypiatek/42553a6364fb2ccc8a81dcea570fdde1 to your computer and use it in GitHub Desktop.
Setting version for VisualStudio extensions based on the Version msbuild parameter
<Project>
<Target Name="GenerateAssemblyInfo" BeforeTargets="BeforeBuild">
<PropertyGroup>
<AssemblyInfoFileLines><![CDATA[
[assembly: System.Reflection.AssemblyFileVersionAttribute("$(Version)")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("$(Version)")]
[assembly: System.Reflection.AssemblyVersionAttribute("$(Version)")]
]]></AssemblyInfoFileLines>
</PropertyGroup>
<WriteLinesToFile Lines="$(AssemblyInfoFileLines)" File="$(IntermediateOutputPath)\AssemblyInfo.g.cs" Overwrite="true" />
<Message Text="Generate assembly info" Importance="high" />
</Target>
<Target Name="IncludeAssemblyInfo" BeforeTargets="BeforeBuild" AfterTargets="GenerateAssemblyInfo">
<ItemGroup>
<Compile Include="$(IntermediateOutputPath)\AssemblyInfo.g.cs" />
</ItemGroup>
<Message Text="Include assembly info" Importance="high" />
</Target>
<Target Name="SetVersionForVsixManifest" BeforeTargets="BeforeBuild">
<PropertyGroup>
<Namespace>
<Namespace Prefix="d" Uri="http://schemas.microsoft.com/developer/vsx-schema/2011" />
</Namespace>
</PropertyGroup >
<XmlPoke
XmlInputPath="source.extension.vsixmanifest"
Value="$(Version)"
Query="/d:PackageManifest/d:Metadata/d:Identity/@Version"
Namespaces="$(Namespace)"
/>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment