开发者

Fetching labeled files into a TFSBuild

开发者 https://www.devze.com 2023-03-30 07:46 出处:网络
I am sure there is a simple answer to this, but my google-fu fails me. I have a team project in TFS 2008 that builds OK when using the latest code, however I now have a need to fetch the previous ver

I am sure there is a simple answer to this, but my google-fu fails me.

I have a team project in TFS 2008 that builds OK when using the latest code, however I now have a need to fetch the previous versions of a subset of the files at build time. The subset of files are all labeled with the same label ("MyLabel" in the snippet below).

The snippet of XML I have added to be TFSBuild.proj file looks like this:

  <PropertyGroup>
    <BuildLabel>LMyLabel</BuildLabel>
  </PropertyGroup>

  <Target Name="BeforeCompile">
    <Get
        TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
        BuildUri="$(BuildUri)"
        Condition=" '$(SkipGet)'!='true' "
        Workspace="$(WorkspaceName)"
        Recursive="$(RecursiveGet)"
        Force="$(ForceGet)"
        Version ="$(BuildLabel)" 
        Preview="false"
    />
  </Target>

This successfully fetches the subset of files into the source area, however it also deletes all other files in the source area.

i.e. the build process does the following:

  1. fetch latest versions of all files into the source area
  2. fetch labeled version of subset of files into the source area
  3. delete开发者_开发问答 all non-labeled files from the source area
  4. run build

The build fails with the following error: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(997,5): error MSB3491: Could not write lines to file "[build directory]\Sources\MySolution.sln.x64.Release.vsprops". Could not find a part of the path '[build directory]\Sources\MySolution.x64.Release.vsprops'.

(which basically indicates that it can't find the solution, because it's been deleted)

I've tried adding the following snippet to the bottom of the XML:

  <PropertyGroup>
    <SkipClean>true</SkipClean>
    <SkipInitializeWorkspace>true</SkipInitializeWorkspace>
    <ForceGet>false</ForceGet>
  </PropertyGroup>
</Project>

but the result is the same.

So, my question is: how do I build my solution when it is a mixture of latest versions and older, labeled versions? What am I missing?

(I realize I could just branch the baseline but for various reasons I would like to explore this approach first)

Thanks in advance!


Just a simple approach that come to mind:

  1. Get your latest version to workspace1
  2. Get your labeled version to workspace2
  3. XCopy workspace1 content over workspace2 as a post-get action

What do you think? Worth the try?


Looking at C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets, it appears that the version fetched for the build is controlled by the GetVersion property. And that ForceGet is true by default.

I haven't tested it, but that implies to me that if you put

/property:GetVersion=*versionspec*

in the MSBuild Command Line Arguments textbox when you queue the build, it should fetch the specified version (look here for versionspec syntax. If this fails for some reason, read Aaron Hallberg's blog until you understand msbuild better than I do:-)

0

精彩评论

暂无评论...
验证码 换一张
取 消