|
|
1
2
可以同时使用不相交的工作区映射+递归。你得小心点。 这将获取foo&bar中的所有c_文件:
这通常在foo&bar下获取所有内容,但如果工作目录无法明确解析为工作区,则会失败:
这可能有效(同样的警告如上),但它可能不会达到你期望的效果!
还有更多的变化;行为取决于工作区的定义方式,以及同一台机器上具有类似本地路径的其他工作区的存在。你能准确地说出你的构建定义吗?您是否可以添加一些调试语句来验证在执行目标时,哪些$(solutionRoot)和其他msbuild属性是相等的? 编辑/ 如我所说,不相交的映射+递归很难纠正。结果发现,行为不仅随文件规范和工作区定义的细微细节而变化,而且随命令的不同而变化!与我的第一个例子不同,这失败了:
迷惑了吗?我是,我在TFS团队工作了几年! 让我从各种评论主题中总结我的建议:
|
|
|
2
1
我的脚本现在正在工作,有几个小问题导致了这个问题。一个是对于许多命令,您必须引用精确的工作目录(本地文件夹),以便命令工作。另一个问题是设置属性需要移动到自定义任务中,以便另一个任务能够正确使用它们。所以希望下面的完整构建脚本能够帮助其他人。在任何编辑器中粘贴它都会使阅读更容易。 <!-- Generate all of the project specific variables we will need for versioning -->
<PropertyGroup>
<VersioningFile>$(SolutionRoot)\TEAM-MAIN\Address Finalizer\Address Finalizer\versionNumber.txt</VersioningFile>
<TfCommand>"$(TeamBuildRefPath)\..\tf.exe"</TfCommand>
<WorkingDirectory>$(SolutionRoot)\TEAM-MAIN\Address Finalizer</WorkingDirectory>
<WorkingDirectory2>$(SolutionRoot)\TEAM-MAIN\HH-CAHPS Project\MAINLINE\3rd Party</WorkingDirectory2>
<DllName>Address_Finalizer.dll</DllName>
<PublishedFolder>$(SolutionRoot)\TEAM-MAIN\HH-CAHPS Project\MAINLINE\3rd Party\bin\PG File Import</PublishedFolder>
<LabelPath>unknown</LabelPath>
</PropertyGroup>
<!-- Only edit the properties when usign this as a template for other builds -->
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="AfterGet">
<Message Text="FOOBAR Version File: $(VersioningFile)" />
<Message Text="FOOBAR Working Dir : $(WorkingDirectory)" />
<!-- Report what our working folders are -->
<Exec
Command='$(TfCommand) workfold'
WorkingDirectory="$(WorkingDirectory)"/>
<!-- Generate the version # -->
<CallTarget Targets="GenerateVersion"/>
<!-- Version the assemblies -->
<CallTarget Targets="VersionAssemblies"/>
<!-- Configure the deployment for QA -->
<CallTarget Targets="ConfigureForQA"/>
<!-- Apply a label to everything -->
<CallTarget Targets="LabelWorkingDirectory"/>
<CallTarget Targets="LabelWorkingDirectory2"/>
</Target>
<Target Name="AfterDropBuild">
<!-- Generate all of the project specific variables we will need for deployment, dependant on versioning -->
<PropertyGroup>
<ReleaseDLL>$(DropLocation)\$(BuildNumber)\Release\$(DllName)</ReleaseDLL>
<PublishedDLL>$(PublishedFolder)\$(DllName)</PublishedDLL>
</PropertyGroup>
<!-- Check out the published DLL -->
<Exec
Command='$(TfCommand) checkout /lock:checkout "$(PublishedDLL)"'
WorkingDirectory="$(WorkingDirectory)" />
<!-- Copy release to published -->
<Copy
SourceFiles="$(ReleaseDLL)"
DestinationFolder="$(PublishedFolder)"/>
<!-- Check in the published DLL -->
<Exec
Command='$(TfCommand) checkin /override:Automated /noprompt /comment:"$(VersionComment)" "$(PublishedDLL)"'
WorkingDirectory="$(WorkingDirectory)" />
</Target>
<Target Name="GenerateVersion">
<!-- Check out the version file -->
<Exec
Command='$(TfCommand) checkout /lock:checkout "$(VersioningFile)"'
WorkingDirectory="$(SolutionRoot)"/>
<!-- Increment the revision # in the file and save it -->
<Version VersionFile="$(VersioningFile)" BuildType="None" RevisionType="Increment">
<Output TaskParameter="Major" PropertyName="Major" />
<Output TaskParameter="Minor" PropertyName="Minor" />
<Output TaskParameter="Build" PropertyName="Build" />
<Output TaskParameter="Revision" PropertyName="Revision" />
</Version>
<!-- Pad the revision out to 3 digits. -->
<PropertyGroup>
<PaddedRevision Condition="$(Revision) < 1000">$(Revision)</PaddedRevision>
<PaddedRevision Condition="$(Revision) < 100">0$(Revision)</PaddedRevision>
<PaddedRevision Condition="$(Revision) < 10">00$(Revision)</PaddedRevision>
</PropertyGroup>
<!-- Generate what our version string looks like for the logfile -->
<CreateProperty Value="Address Finalizer $(Major).$(Minor).$(Build) Build $(PaddedRevision)">
<Output TaskParameter="Value" PropertyName="ProjectVersion" />
</CreateProperty>
<CreateProperty Value="Automated build: $(ProjectVersion)">
<Output TaskParameter="Value" PropertyName="VersionComment" />
</CreateProperty>
<Message Text="New Version is: $(ProjectVersion)"/>
<!-- Check in the version file -->
<Exec
Command='$(TfCommand) checkin /noprompt /comment:"$(VersionComment)" "$(VersioningFile)"'
WorkingDirectory="$(SolutionRoot)"/>
</Target>
<Target Name="VersionAssemblies">
<!-- Get all of the assemblyinfo files from all of the directories (should only be one) -->
<ItemGroup>
<AssemblyInfoList Include="$(SolutionRoot)\**\assemblyinfo.cs"/>
</ItemGroup>
<Message Text="FOOBAR Build Dir : $(MSBuildProjectDirectory)"/>
<Message Text="FOOBAR Solution Root: $(SolutionRoot)"/>
<Message Text="FOOBAR Working Dir : $(WorkingDirectory)"/>
<!-- Check out all of the assemblyInfo files -->
<Exec
Command="$(TfCommand) checkout AssemblyInfo.cs /recursive"
WorkingDirectory="$(WorkingDirectory)"
ContinueOnError="false"/>
<!-- Change the version # on all of the assemblyInfo files -->
<MSBuild.ExtensionPack.Framework.AssemblyInfo AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)" AssemblyInfoFiles="@(AssemblyInfoList)"/>
<MSBuild.ExtensionPack.Framework.AssemblyInfo AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)" AssemblyInfoFiles="@(AssemblyInfoList)"/>
<!-- Check in all of the assemblyInfo files -->
<Exec
Command='$(TfCommand) checkin /override:Automated /comment:"$(VersionComment)" /noprompt AssemblyInfo.cs /recursive'
WorkingDirectory="$(WorkingDirectory)"
ContinueOnError="false"/>
</Target>
<Target Name="ConfigureForQA">
<!-- Grab all of the QA app.config files (should only be one) -->
<CreateItem Include="$(SolutionRoot)\**\app-qa.config">
<Output TaskParameter ="Include" ItemName ="AppConfigFiles"/>
</CreateItem>
<!-- Copy the QA app.config to app.config to make it the driving config file -->
<Copy
SourceFiles="@(AppConfigFiles)"
OverwriteReadOnlyFiles="True"
DestinationFiles="@(AppConfigFiles->'$(SolutionRoot)\%(RecursiveDir)app%(Extension)')"/>
</Target>
<Target Name="LabelWorkingDirectory">
<Message Text="FOOBAR Version: $(ProjectVersion)" />
<Message Text="FOOBAR Comment: $(VersionComment)" />
<Message Text="FOOBAR Path : $(LabelPath)" />
<!-- Apply Label on workspace -->
<Label
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Name="$(ProjectVersion)"
Files="$(WorkingDirectory)"
Comments="$(VersionComment)"
ContinueOnError="False"
Recursive="True" />
</Target>
<Target Name="LabelWorkingDirectory2">
<Message Text="FOOBAR Version: $(ProjectVersion)" />
<Message Text="FOOBAR Comment: $(VersionComment)" />
<Message Text="FOOBAR Path : $(LabelPath)" />
<!-- Apply Label on workspace -->
<Label
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Name="$(ProjectVersion)"
Files="$(WorkingDirectory2)"
Comments="$(VersionComment)"
ContinueOnError="False"
Recursive="True" />
</Target>
|
|
|
urlreader · 是否将自定义列添加到TFS中的UI? 8 年前 |
|
|
Mkram · Microsoft TFS研究 8 年前 |
|
|
ab_732 · TFS如何从代码审阅中排除DLL和代码注释/空白 8 年前 |
|
|
gvdm · 如何控制TFS的配置 8 年前 |
|
|
Buda Gavril · SonarQube分析任务更改构建的输出 8 年前 |