问题
We are currently setting up Team Build 2010 for our company, and I am trying to use workflow activities to retrieve the exact local path to the current solution being built. I haven't found a way to get this value, does anybody know how (without writing a custom activity)?
Either one of server or local path would suffice (i.e $/TeamProject/Branch/OurProject
or C:\TeamBuild\src\path\to\branch\OurProject
) since we can use the conversion activities on the server item.
The reason we need this path is for updating version info files, and that needs to be done for only the current solution being built, and the files have the same names (AssemblyInfo.cs, for example).
In this similar question, the solution is to define a parameter, but since this information is particular to the solution being built and not some external path, we were hoping that this info would retrievable.
回答1:
You can retrieve this particular info without adding anything. If you navigate within your Build Process Template to the position where MSBuild breaks out, you will see that the solution that shall be build is set as a string named localProject
.
This will contain the local path where TFS has downloaded your SLN, something like C:\TeamBuild\src\path\to\branch\OurProject\OurProject.sln
.
Open the XAML and navigate to:
Run On Agent
Try Compile, Test, and Associate Changesets and Work Items
Compile, Test, and Associate Changesets and Work Items
Try Compile and Test
Compile and Test
For Each Configuration in BuildSettings.PlatformConfigurations
Compile and Test for Configuration
If BuildSettings.HasProjectsToBuild
For Each Project in BuildSettings.ProjectsToBuild
Try to Compile the Project
Compile the Project
Run MSBuild for Project
if you select Run MSBuild for Project
& hit F4
you see it.
In order to retrieve what you are after you can define another string-variable solutionPath
in your Build Process Template & insert under the Run MSBuild for Project
a new Assign
activity withTo : solutionPath
andValue : Path.GetDirectoryName(localProject)
回答2:
Have you looked at the TFS Community Build Extensions, they give you a assembly versioning out of the box?
You can use the variable called
SourcesDirectory
to get the current Source Directory on the Build Server. You can also use anConvertWorkspaceItem
activity to convert between server and local paths.
There's also a blog post that cover's all of this here.
来源:https://stackoverflow.com/questions/9536873/retrieving-path-to-solutions