排除 teamcity 工件中的文件类型

发布于 2024-09-26 19:33:30 字数 336 浏览 0 评论 0原文

我正准备第一次自己设置 teamcity。我不得不说,在大多数方面都非常好而且简单。但是,我有一个问题尚未解决并找到任何相关信息。

当我想发布我的工件时,我想排除某些文件类型。

示例:

%system.agent.work.dir%\trunk\Source\Projects\Webproject.Web/Controllers => Webproject.Web/Controllers

但是,我不想复制文件夹中的所有 .cs 文件。我只需要文件夹。 是否可以仅复制文件夹而不复制内容,然后复制我需要的内容?或者,如果复制目录,我可以排除文件吗?

I'm just about to setup teamcity for the first time on my own. Very nice and simple in most ways I have to say. However, I have one issue that I haven't manage to solve and find any information about.

When I wanna publish my artifacts I want to exclude some file types.

example:

%system.agent.work.dir%\trunk\Source\Projects\Webproject.Web/Controllers => Webproject.Web/Controllers

However, I don't want to copy all the .cs files in the folder. I just need the folder.
Is it possible to copy just the folder and not the content, and then copy what ever content I need? Or can I exclude files if I copy a directory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青芜 2024-10-03 19:33:30

您可以添加一个 MSBUILD 目标,它为您准备“部署”包。我有以下内容(可能需要对您的项目进行一些更改):

  <Target Name="Publish" DependsOnTargets="Build" Condition="'$(WebProjectOutputDir)'!=''">
    <RemoveDir Directories="$(WebProjectOutputDir)" ContinueOnError="true" />
    <!-- Log tasks -->
    <Message Text="Publishing web application for $(MSBuildProjectName)" />
    <Message Text="WebProjectOutputDir: $(WebProjectOutputDir)" />
    <!-- Create the _PublishedWebsites\app\bin folder -->
    <MakeDir Directories="$(WebProjectOutputDir)\bin" />
    <!-- Copy build outputs to _PublishedWebsites\app\bin folder -->
    <Copy SourceFiles="@(IntermediateAssembly)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(AddModules)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <Copy SourceFiles="$(IntermediateOutputPath)$(_SGenDllName)" DestinationFolder="$(WebProjectOutputDir)\%(Content.SubFolder)%(Content.RecursiveDir)" SkipUnchangedFiles="true" Condition="'$(_SGenDllCreated)'=='true'" />
    <Copy SourceFiles="$(IntermediateOutputPath)$(TargetName).pdb" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DebugSymbolsProduced)'=='true'" />
    <Copy SourceFiles="@(DocFileItem)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DocumentationFileProduced)'=='true'" />
    <Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)" DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(WebProjectOutputDir)\bin\%(Culture)\$(TargetName).resources.dll')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
    <Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFiles="@(ReferenceCopyLocalPaths->'$(WebProjectOutputDir)\bin\%(DestinationSubDirectory)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
    <!-- Copy content files recursively to _PublishedWebsites\app\ folder -->
    <Copy SourceFiles="@(Content)" DestinationFolder="$(WebProjectOutputDir)\%(Content.RelativeDir)" />
    <!-- Copy items that have been marked to be copied to the bin folder -->
    <Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectory)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectoryAlways)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="false" />
  </Target>

因此,在 TC 构建中,我使用 MSBUILD 构建器,如下所示:

Targets: Rebuild;Publish

Command line parameters: /p:WebProjectOutputDir="%system.teamcity.build.workingDir%\Website"

然后您可以使用 Website 目录作为您的工件。

You can add a MSBUILD target which prepares the "deployment" package for you. I have the following (may need some changes for your project):

  <Target Name="Publish" DependsOnTargets="Build" Condition="'$(WebProjectOutputDir)'!=''">
    <RemoveDir Directories="$(WebProjectOutputDir)" ContinueOnError="true" />
    <!-- Log tasks -->
    <Message Text="Publishing web application for $(MSBuildProjectName)" />
    <Message Text="WebProjectOutputDir: $(WebProjectOutputDir)" />
    <!-- Create the _PublishedWebsites\app\bin folder -->
    <MakeDir Directories="$(WebProjectOutputDir)\bin" />
    <!-- Copy build outputs to _PublishedWebsites\app\bin folder -->
    <Copy SourceFiles="@(IntermediateAssembly)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(AddModules)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <Copy SourceFiles="$(IntermediateOutputPath)$(_SGenDllName)" DestinationFolder="$(WebProjectOutputDir)\%(Content.SubFolder)%(Content.RecursiveDir)" SkipUnchangedFiles="true" Condition="'$(_SGenDllCreated)'=='true'" />
    <Copy SourceFiles="$(IntermediateOutputPath)$(TargetName).pdb" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DebugSymbolsProduced)'=='true'" />
    <Copy SourceFiles="@(DocFileItem)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DocumentationFileProduced)'=='true'" />
    <Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)" DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(WebProjectOutputDir)\bin\%(Culture)\$(TargetName).resources.dll')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
    <Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFiles="@(ReferenceCopyLocalPaths->'$(WebProjectOutputDir)\bin\%(DestinationSubDirectory)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
    <!-- Copy content files recursively to _PublishedWebsites\app\ folder -->
    <Copy SourceFiles="@(Content)" DestinationFolder="$(WebProjectOutputDir)\%(Content.RelativeDir)" />
    <!-- Copy items that have been marked to be copied to the bin folder -->
    <Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectory)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectoryAlways)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="false" />
  </Target>

So, in the TC build, I use the MSBUILD builder like this:

Targets: Rebuild;Publish

Command line parameters: /p:WebProjectOutputDir="%system.teamcity.build.workingDir%\Website"

You can then use the Website directory as your artifact.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文