DefineCustomFiles and CustomCollectFiles are not f

2020-07-25 10:44发布

I'm trying to publish extra files with TeamCity. I also opened a subject here: Publish extra dll files not included in the web project but here I'm focused on the fact that DefineCustomFiles and CustomCollectFiles seem not fired.

My build step looks like this:

TeamCity build step

And my custom build file looks like this :

<?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>

The example01.txt file is at the root of my project, like my custom build file.

Problems:

  • I can't see the DefineCustomFiles and CustomCollectFiles targets fired in TeamCity's log
  • My example file is not added during the publication

Thanks for any help!

UPDATE

The problem comes from the separate file! Now I use the standard .csproj file with this at the end:

<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>

And it works, oh yeah!!

UPDATE

And my build step in Team City is finally:

enter image description here

0条回答
登录 后发表回答