Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parameter "OnlyIfChanged" to AssemblyInfo task to avoid recompilations #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants