1

我有这个解决方案(Project1),它有 2 个 Web 应用程序项目和 3 个依赖库项目。主要的 Web 应用程序项目使用发布配置文件构建和部署就好了,但是,第二个 Web 应用程序项目是一个 API(如下所述),其发布配置文件的名称与主项目相同,但当然,它们会转到不同的位置。不幸的是,该项目将在 VS2019 中使用发布配置文件进行构建和部署,但是,当使用 MSBuild 命令(TeamCity 服务器)时:

MSBuild.exe /m /p:DeployOnBuild=True /p:PublishProfile=Test /t:Rebuild

我收到以下错误:

CopyAllFilesToSingleFolderForAspNetCompileMerge:
    Creating directory "obj\Debug\AspnetCompileMerge\Source".
    Copying all files to temporary location below for package/publish:
    obj\Debug\AspnetCompileMerge\Source.
    Copying bin\KuderCore.API.dll to obj\Debug\AspnetCompileMerge\Source\bin\Project1.API.dll.
    Copying bin\KuderCore.API.pdb to obj\Debug\AspnetCompileMerge\Source\bin\Project1.API.pdb.
    Copying Areas\HelpPage\HelpPage.css to obj\Debug\AspnetCompileMerge\Source\Areas\HelpPage\HelpPage.css.
    Copying Content\bootstrap-theme.css to obj\Debug\AspnetCompileMerge\Source\Content\bootstrap-theme.css.
    Copying Content\bootstrap-theme.min.css to obj\Debug\AspnetCompileMerge\Source\Content\bootstrap-theme.min.css.
    Copying Content\bootstrap.css to obj\Debug\AspnetCompileMerge\Source\Content\bootstrap.css.
    Copying Content\bootstrap.min.css to obj\Debug\AspnetCompileMerge\Source\Content\bootstrap.min.css.
    Copying favicon.ico to obj\Debug\AspnetCompileMerge\Source\favicon.ico.
    Copying fonts\glyphicons-halflings-regular.svg to obj\Debug\AspnetCompileMerge\Source\fonts\glyphicons-halflings-regular.svg.
    Copying Global.asax to obj\Debug\AspnetCompileMerge\Source\Global.asax.
    Copying Properties\PublishProfiles\Test.pubxml.user to obj\Debug\AspnetCompileMerge\Source\Properties\PublishProfiles\Test.pubxml.user.
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VisualStudio\v16.0\Web\Transform\
        Microsoft.Web.Publishing.AspNetCompileMerge.targets(615,5): error : Copying file Properties\PublishProfiles\
        Test.pubxml.user to obj\Debug\AspnetCompileMerge\Source\Properties\PublishProfiles\
        Test.pubxml.user failed. Could not find file 'Properties\PublishProfiles\Test.pubxml.user'
    Done Building Project "Project1\Project1.API\Project1.API.csproj" (Rebuild target(s)) -- FAILED.

Build FAILED.

出于某种原因,MSBuild 没有生成 .user 文件,而是在轰炸。知道发生了什么吗?

4

1 回答 1

0

我今天遇到了这个问题。问题是 pubxml.user 文件已添加到 .gitignore 但也包含在解决方案中。这意味着该文件在 .csproj 中有一个构建操作,因此当发布步骤发生时,msbuild 正在寻找可能不存在的文件。

由于该文件应该被忽略,它可能不应该在 .csproj 中。我发现两种解决方案都有效:

  1. 从解决方案中删除文件,从而删除 .csproj。
  2. 将构建操作设置为“无”。这可以在文件的属性中进行配置。

无论哪种方式,msbuild 在执行发布步骤时都将不再查找文件,并且构建应该可以工作。

于 2021-10-15T23:57:49.543 回答