我正在尝试使用 TeamCity 发布额外的文件。我还在这里打开了一个主题:发布未包含在 web 项目中的额外 dll 文件,但在这里我关注的是 DefineCustomFiles 和 CustomCollectFiles 似乎没有被触发的事实。
我的构建步骤如下所示:
我的自定义构建文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<PropertyGroup>
<Configuration>Release</Configuration>
<CopyAllFilesToSingleFolderForPackageDependsOn>
DefineCustomFiles;
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="BuildAll" DependsOnTargets="Compile">
<Message Text="=== BuildAll ===" Importance="high" />
</Target>
<Target Name="Compile">
<Message Text="=== Compile ===" Importance="high" />
<MSBuild Projects="$(SolutionFile)" Properties="Configuration=$(Configuration)" />
</Target>
<Target Name="DefineCustomFiles">
<Message Text="=== DefineCustomFiles ===" Importance="high" />
<ItemGroup>
<CustomFilesToInclude Include="example01.txt" />
</ItemGroup>
</Target>
<Target Name="CustomCollectFiles">
<Message Text="=== CustomCollectFiles ===" Importance="high" />
<ItemGroup>
<FilesForPackagingFromProject Include="@(CustomFilesToInclude)">
<DestinationRelativePath>%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
</Project>
example01.txt 文件位于我的项目的根目录,就像我的自定义构建文件一样。
问题:
- 我看不到 TeamCity 日志中触发的 DefineCustomFiles 和 CustomCollectFiles 目标
- 发布期间未添加我的示例文件
谢谢你的帮助!
更新
问题来自单独的文件!现在我在最后使用标准的 .csproj 文件:
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<Message Text="=== CustomCollectFiles ===" Importance="high" />
<ItemGroup>
<_CustomFiles Include="..\Extra Files\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
它有效,哦,是的!
更新
我在 Team City 的构建步骤终于是: