Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Conversation

@jokedst
Copy link

@jokedst jokedst commented Jan 26, 2015

When recompiling big projects with this tool all projects needs to be recompiled every time since the generated file changes date (even if it's identical).

I added a parameter "OnlyIfChanged" to the AssemblyInfo task; when true it checks if any existing file is identical, if so it doesn't update the file (and thus keeps the date unchanged). This allows the compilation of projects to be skipped if it's up to date.

@tkouba
Copy link

tkouba commented Jul 22, 2015

Simple workaround is property Inputs and Outputs on Target. MSBuild has built-in support for compile optimizations, so Target UpdateVersionFiles is executed only when necessary

<PropertyGroup>
<BuildDependsOn>
    UpdateVersionFiles;
    $(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>

<Target Name="UpdateVersionFiles"
      Inputs="$(SourceVersionFile)"
      Outputs="$(SolutionVersionFile)">
<!-- Check out version files -->
<Exec Command="$(TF) checkout &quot;$(SolutionVersionFile)&quot;" WorkingDirectory="$(SolutionRoot)" ContinueOnError="true" IgnoreExitCode="true" />

<!-- Workaround: Version task must have read/write access -->
<Attrib Files="$(SourceVersionFile)" ReadOnly="false" />

<!-- Get build number -->
<Version VersionFile="$(SourceVersionFile)" BuildType="None" RevisionType="None">
  <Output TaskParameter="Major" PropertyName="BuildVersionMajor" />
  <Output TaskParameter="Minor" PropertyName="BuildVersionMinor" />
  <Output TaskParameter="Build" PropertyName="BuildVersionBuild" />
  <Output TaskParameter="Revision" PropertyName="BuildVersionRevision" />
</Version>
<Attrib Files="$(SolutionVersionFile)" ReadOnly="false" />
<AssemblyInfo CodeLanguage="CS"
            OutputFile="$(SolutionVersionFile)"
            AssemblyVersion="$(BuildVersionMajor).$(BuildVersionMinor).$(BuildVersionBuild).$(BuildVersionRevision)" />
</Target>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants