Note that there are some explanatory texts on larger screens.

plurals
  1. POMSBuild Expansion Pack: AssemblyInfo - Not behaving as expected
    primarykey
    data
    text
    <p>I am trying to get MSBuild to automatically update a project's AssemblyVersion and AssemblyFileVersion.</p> <p>Specifically, just the build and revision number.</p> <p>So, if my source file starts out as</p> <pre><code>[assembly: AssemblyVersion("1.2.3.4")] </code></pre> <p>and my build and revision numbers are 13 and 14, I want this to become:</p> <pre><code>[assembly: AssemblyVersion("1.2.13.14")] </code></pre> <p>However, I am not getting the expected outcome. Instead, I am getting something like this - presumably because it is the 28th of November at the time I did the build.</p> <pre><code>[assembly: AssemblyVersion("1.0.1128.01")] </code></pre> <p>Relevant info from my .csproj file below.</p> <pre><code> &lt;Import Project="$(MSBuildExtensionsPath64)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/&gt; &lt;Import Project="$(MSBuildExtensionsPath64)\ExtensionPack\4.0\MSBuild.ExtensionPack.VersionNumber.targets"/&gt; &lt;PropertyGroup&gt; &lt;BuildDependsOn&gt; AssemblyVersion; $(BuildDependsOn) &lt;/BuildDependsOn&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;AssemblyVersionFiles Include="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs"/&gt; &lt;/ItemGroup&gt; &lt;Target Name="AssemblyVersion" Inputs="@(AssemblyVersionFiles)" Outputs="UpdatedAssemblyVersionFiles"&gt; &lt;Message Text="Setting AssemblyVersion..." Importance="High" /&gt; &lt;AssemblyInfo AssemblyInfoFiles="%(AssemblyVersionFiles.FullPath)" AssemblyBuildNumber="12" AssemblyBuildNumberType="NoIncrement" AssemblyRevision="13" AssemblyRevisionType="NoIncrement" /&gt; &lt;/Target&gt; </code></pre> <p>At this point I'm just about ready to scrap the extensions altogether, split my assembly and file versions out into two separate files, and use powershell to read and overwrite their values. Might be a more desireable solution as it'll only be able to take place on the build machine so I won't have to worry about developers getting odd build results if they don't have the expansion pack installed.</p> <p>Still, I don't like to be beaten, so I'd love to find out how to make this work.</p> <p>Any thoughts?</p> <hr> <p>Full .csproj file below:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; &lt;PropertyGroup&gt; &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt; &lt;Platform Condition=" '$(Platform)' == '' "&gt;x86&lt;/Platform&gt; &lt;ProductVersion&gt;8.0.30703&lt;/ProductVersion&gt; &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt; &lt;ProjectGuid&gt;{452FDE9A-EAFE-44EF-A7AD-34F287AE1664}&lt;/ProjectGuid&gt; &lt;OutputType&gt;WinExe&lt;/OutputType&gt; &lt;AppDesignerFolder&gt;Properties&lt;/AppDesignerFolder&gt; &lt;RootNamespace&gt;AssemblyInfoTest&lt;/RootNamespace&gt; &lt;AssemblyName&gt;AssemblyInfoTest&lt;/AssemblyName&gt; &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt; &lt;TargetFrameworkProfile&gt;Client&lt;/TargetFrameworkProfile&gt; &lt;FileAlignment&gt;512&lt;/FileAlignment&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "&gt; &lt;PlatformTarget&gt;x86&lt;/PlatformTarget&gt; &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt; &lt;DebugType&gt;full&lt;/DebugType&gt; &lt;Optimize&gt;false&lt;/Optimize&gt; &lt;OutputPath&gt;bin\Debug\&lt;/OutputPath&gt; &lt;DefineConstants&gt;DEBUG;TRACE&lt;/DefineConstants&gt; &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt; &lt;WarningLevel&gt;4&lt;/WarningLevel&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "&gt; &lt;PlatformTarget&gt;x86&lt;/PlatformTarget&gt; &lt;DebugType&gt;pdbonly&lt;/DebugType&gt; &lt;Optimize&gt;true&lt;/Optimize&gt; &lt;OutputPath&gt;bin\Release\&lt;/OutputPath&gt; &lt;DefineConstants&gt;TRACE&lt;/DefineConstants&gt; &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt; &lt;WarningLevel&gt;4&lt;/WarningLevel&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;Reference Include="System" /&gt; &lt;Reference Include="System.Core" /&gt; &lt;Reference Include="System.Xml.Linq" /&gt; &lt;Reference Include="System.Data.DataSetExtensions" /&gt; &lt;Reference Include="Microsoft.CSharp" /&gt; &lt;Reference Include="System.Data" /&gt; &lt;Reference Include="System.Deployment" /&gt; &lt;Reference Include="System.Drawing" /&gt; &lt;Reference Include="System.Windows.Forms" /&gt; &lt;Reference Include="System.Xml" /&gt; &lt;/ItemGroup&gt; &lt;ItemGroup&gt; &lt;Compile Include="Form1.cs"&gt; &lt;SubType&gt;Form&lt;/SubType&gt; &lt;/Compile&gt; &lt;Compile Include="Form1.Designer.cs"&gt; &lt;DependentUpon&gt;Form1.cs&lt;/DependentUpon&gt; &lt;/Compile&gt; &lt;Compile Include="Program.cs" /&gt; &lt;Compile Include="Properties\AssemblyInfo.cs" /&gt; &lt;EmbeddedResource Include="Properties\Resources.resx"&gt; &lt;Generator&gt;ResXFileCodeGenerator&lt;/Generator&gt; &lt;LastGenOutput&gt;Resources.Designer.cs&lt;/LastGenOutput&gt; &lt;SubType&gt;Designer&lt;/SubType&gt; &lt;/EmbeddedResource&gt; &lt;Compile Include="Properties\Resources.Designer.cs"&gt; &lt;AutoGen&gt;True&lt;/AutoGen&gt; &lt;DependentUpon&gt;Resources.resx&lt;/DependentUpon&gt; &lt;/Compile&gt; &lt;None Include="Properties\Settings.settings"&gt; &lt;Generator&gt;SettingsSingleFileGenerator&lt;/Generator&gt; &lt;LastGenOutput&gt;Settings.Designer.cs&lt;/LastGenOutput&gt; &lt;/None&gt; &lt;Compile Include="Properties\Settings.Designer.cs"&gt; &lt;AutoGen&gt;True&lt;/AutoGen&gt; &lt;DependentUpon&gt;Settings.settings&lt;/DependentUpon&gt; &lt;DesignTimeSharedInput&gt;True&lt;/DesignTimeSharedInput&gt; &lt;/Compile&gt; &lt;/ItemGroup&gt; &lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&gt; &lt;!--&lt;Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/&gt;--&gt; &lt;Import Project="$(MSBuildExtensionsPath64)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/&gt; &lt;Import Project="$(MSBuildExtensionsPath64)\ExtensionPack\4.0\MSBuild.ExtensionPack.VersionNumber.targets"/&gt; &lt;PropertyGroup&gt; &lt;BuildDependsOn&gt; AssemblyVersion; $(BuildDependsOn) &lt;/BuildDependsOn&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;AssemblyVersionFiles Include="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs"/&gt; &lt;/ItemGroup&gt; &lt;Target Name="AssemblyVersion" Inputs="@(AssemblyVersionFiles)" Outputs="UpdatedAssemblyVersionFiles"&gt; &lt;Message Text="Setting AssemblyVersion..." Importance="High" /&gt; &lt;AssemblyInfo SkipVersioning="true" AssemblyInfoFiles="%(AssemblyVersionFiles.FullPath)" AssemblyBuildNumber="12" AssemblyBuildNumberType="NoIncrement" AssemblyRevision="13" AssemblyRevisionType="NoIncrement" /&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload