1

I have this solution (Project1) and that has 2x web app projects and 3x dependent library projects. The primary web app project builds and deploys using publish profiles just fine, however, the second web app project is an API (noted below) with publish profiles named the same as the main project, but of course, are going to different locations. Unfortunately, the project will build and deploy using the publish profiles just fine in VS2019, however, when using the MSBuild command (TeamCity server):

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

I get the following error:

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.

For some reason, MSBuild isn't generating a .user file and it is bombing instead. Any idea what is going on?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Deadder
  • 535
  • 1
  • 4
  • 16
  • Try to use command line: `MSBuild.exe /m /p:DeployOnBuild=True /p:PublishProfile=Test /t:Rebuild -v:detailed` to get the detailed deploy log and see what happens. – Mr Qian Aug 24 '20 at 01:43
  • Thanks @PerryQian-MSFT - I tried that, but there is no additional error output with that extra parameter. A bunch of useless info - but that section of the output reamined the same. – Deadder Aug 24 '20 at 15:03

1 Answers1

0

I ran into this problem today. The problem is that the pubxml.user file is added to the .gitignore but is also included in the solution. This means the file has a build action in the .csproj, and so when the publish step happens, msbuild is looking for the file, which may not exist.

Since the file is supposed to be ignored, it probably should not be in the .csproj. Two solutions I found that both worked:

  1. Remove the file from the solution, and thus the .csproj.
  2. Set the build action to "None". This is configurable in the properties for a file.

Either way, msbuild will no longer look for the file when executing the publish step, and the build should work.

Charles
  • 113
  • 3
  • 10