TeamCity 不会创建发布文件夹

TeamCity wont create release folder

使用 TeamCity 和 运行构建时,我收到以下错误消息。

13:20:31]Step 1/1: MSBuild (1s)
[13:20:32][Step 1/1] src\DystopiaOnline.proj.teamcity: Build target: BuildSolution
[13:20:32][src\DystopiaOnline.proj.teamcity] BuildSolution
[13:20:32][BuildSolution] C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.proj(36, 5): error MSB4062: The "DystopiaOnline.Build.Tasks.GetUnixTimestamp" task could not be loaded from the assembly C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.Build.Tasks/bin/Release/DystopiaOnline.Build.Tasks.dll. Could not load file or assembly 'file:///C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.Build.Tasks\bin\Release\DystopiaOnline.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
[13:20:32][Step 1/1] Step MSBuild failed

然而,当我 运行 从开发人员命令提示构建时,构建工作正常。查看 C:\TeamCity\buildAgent\workc8eb5050252f271\src\D ystopiaOnline.Build.Tasks\bin 内部仅显示 Debug 文件夹而不是 Release 文件夹。 运行 从开发人员命令提示符构建工作正常,只是从 Team City 构建不行。

当构建是 运行 来自 Team City 且环境变量设置为 prod 时,不应该创建 Release 文件夹吗?是什么原因造成的?有人有什么想法吗?

在我的项目解决方案 .proj 文件中设置了以下条件以确定构建配置。有任何与 team city 合作经验的人都可以就问题所在提供任何建议吗?谢谢。

 <PropertyGroup>
        <Env Condition="'$(Env)' == ''">dev</Env>
        <VersionNumber Condition="'$(VersionNumber)' == ''">1</VersionNumber>
        <MSBuildCommunityTasksPath>$(MSBuildThisFileDirectory)/Tasks</MSBuildCommunityTasksPath>
        <UnityPath Condition="'$(UnityPath)' == ''">c:\Program Files (x86)\Unity</UnityPath>
      </PropertyGroup>

      <PropertyGroup Condition="'$(Env)' == 'dev'">
        <BuildConfig>Debug</BuildConfig>
        <Domain>mmo.dystopiaOnline.dev</Domain>
        <SetParamsFile>Parameters.Local.config</SetParamsFile>
      </PropertyGroup>

      <PropertyGroup Condition="'$(Env)' == 'prod'">
        <BuildConfig>Release</BuildConfig>
        <Domain>mmo.DystopiaOnline.com</Domain>
        <SetParamsFile>Parameters.Production.config</SetParamsFile>
      </PropertyGroup>

      <PropertyGroup Condition="'$(Env)' == 'sta'">
        <BuildConfig>Release</BuildConfig>
        <Domain>mmo.DystopiaOnline.sta</Domain>
        <SetParamsFile>Parameters.Staging.config</SetParamsFile>
      </PropertyGroup>

TeamCity 构建日志

[11:45:53]Checking for changes
[11:45:53]Collecting changes in 1 VCS root (1s)
[11:45:55]Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
[11:45:55]Publishing internal artifacts
[11:45:55]Checkout directory: C:\TeamCity\buildAgent\workc8eb5050252f271
[11:45:55]Updating sources: server side checkout
[11:45:55]Step 1/1: MSBuild (4s)
[11:45:55][Step 1/1] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\workc8eb5050252f271 "/msbuildPath:C:\Program Files (x86)\MSBuild.0\bin\MSBuild.exe"
[11:45:55][Step 1/1] in directory: C:\TeamCity\buildAgent\workc8eb5050252f271
[11:45:59][Step 1/1] src\DystopiaOnline.proj.teamcity: Build target: BuildSolution
[11:45:59][src\DystopiaOnline.proj.teamcity] BuildSolution
[11:45:59][BuildSolution] MSBuild
[11:45:59][BuildSolution] C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.proj(36, 5): error MSB4062: The "DystopiaOnline.Build.Tasks.GetUnixTimestamp" task could not be loaded from the assembly C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.Build.Tasks/bin/Release/DystopiaOnline.Build.Tasks.dll. Could not load file or assembly 'file:///C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.Build.Tasks\bin\Release\DystopiaOnline.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
[11:45:59][Step 1/1] Process exited with code 1
[11:45:59][Step 1/1] MSBuild output
[11:45:59][Step 1/1] Step MSBuild failed
[11:45:59]Publishing internal artifacts
[11:45:59]Build finished

这是我的项目设置在构建文件夹中的样子。

link to .proj file on OneDrive

手动将发布文件复制到 TeamCity 后出错

C:\Program Files (x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(3797, 5): error MSB3027: Could not copy "C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.Base\bin\Release\DystopiaOnline.Base.dll" to "bin\Release\DystopiaOnline.Base.dll". Exceeded retry count of 10. Failed.
C:\Program Files (x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(3797, 5): error MSB3021: Unable to copy file "C:\TeamCity\buildAgent\workc8eb5050252f271\src\DystopiaOnline.Base\bin\Release\DystopiaOnline.Base.dll" to "bin\Release\DystopiaOnline.Base.dll". The process cannot access the file 'bin\Release\DystopiaOnline.Base.dll' because it is being used by another process.

您如何在构建中设置参数?它的值很可能没有传递给构建运行器,所以它默认为 dev

<Env Condition="'$(Env)' == ''">dev</Env>

如果您使用的是 teamcity 参数,则它应该是系统或环境参数。您还可以通过单击并转到参数选项卡来检查构建中使用的参数,可能需要仔细检查它是否具有您想要的值。

首先请记住,Windows 路径是“\”而不是“/”。在正常情况下,没有任何不同(例如,当您想在资源管理器中放置路径时),但有时(我 运行 遇到 MsBuild 中某些任务的一些问题)该机制无法识别这是正确的小路。所以将路径更改为

 <MSBuildCommunityTasksPath>$(MSBuildThisFileDirectory)\Tasks\</MSBuildCommunityTasksPath>

(MsBuild 惯例还告诉我们要放置尾部斜杠)

每当您引用 "DystopiaOnline.Build.Tasks.dll" 时:[...]src\DystopiaOnline.Build.Tasks\bin\Release\DystopiaOnline.Build.Tasks.dll


在构建日志中,没有任何迹象表明 MsBuild 尝试构建 DystopiaOnline.Build.Tasks。您如何指定构建项目的顺序?您能否添加这个项目,我们可以准确地看到 MsBuild 想要做什么以及按什么顺序。

如果您在要构建 DystopiaOnline.Build.Tasks 的同一个项目文件中使用 <UsingTask>... 它永远不会工作,因为 MsBuild 首先尝试解析任务然后 运行 目标建造。

当您已经构建项目时,它可以在您的机器上运行,但当(还)没有任何任务时,它不能在干净的环境中运行。

您的 DystopiaOnline.proj 文件中的单词 "Configuraton" 有错别字:

<MSBuild Projects="DystopiaOnline.Build.Tasks/DystopiaOnline.Build.Tasks.csproj" Properties="Configuraton=$(BuildConfig)" />

我认为这是配置构建错误的原因。

尝试创建名为 system.Configuration 的新系统参数并设置值 "Release"