visual-studiotfsmsbuildazure-devopsgetlatest

Enforce GetLatest on file read


Is it possible to force the user to get latest of a file before reading from it?

An example would be for our custom Code Analysis rule set (.ruleset). I do not want someone to run Code Analysis on an old version of the rule set.

We are using Visual Studio Online and Visual Studio 2013 and Team Foundation Version Control.


Solution

  • There is no option in Visual Studio for this, and it doesn't really make sense to always want to enforce this for all files in a workspace, sometimes you need to build against an older version of the code. That said, you could add a pre-build action that uses the TFS commandline to get the latest version of these specific files, something like:

    >TF get $/Project/CodeAnalysisRules/MyProject.Ruleset /version:T
    

    You might need to disable the UseHostCompilerIfAvailable flag in your project file, as it might otherwise not detect the changed file till after the build has completed.