crazyTech
crazyTech

Reputation: 1477

MSBuild publish fails to create zip, and also strangely deletes project code files and directories

We have an solution developed using the following technologies:

The solution contains quite a few WCF Web Services that we deploy to an IIS Server

My plan to have the MSBuild commandline's commands do clean, build, publish.

I wanted to use MSBuild commandline to

I will use MSDeploy to deploy to the IIS Server

Since we are using Visual Studio 2015, it corresponds to Visual Studio Version 14.0 ( Reference: https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#History )

Thus, we should use the following MSBuild executable ( Reference: https://help.veracode.com/r/c_msbuild_paths ):

C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe
C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe
  1. Start to Run Dos Command Prompt in Administrator Mode

  2. Let’s clean the project

D:\Blah\Blah\WCFService>"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:Clean

  1. Let’s build the project

D:\Blah\Blah\WCFService>" C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:Build /p:Configuration=Dev

  1. The problem is with publish ( Note: I don't want to deploy upon build, and that is reason for setting DeployOnBuild=false )

D:\Blah\Blah\WCFService> “C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:_WPPCopyWebApplication;Publish /p:Configuration=Dev
/p:EnvironmentName=Dev WCFService.csproj

/p:DeployOnBuild=false
/p:WebPublishMethod=Package
/p:PackageAsSingleFile=true
/p:DeployTarget=Package /p:PackageLocation="C:\temp\OutputDir\WCFService.zip /p:CreatePackageOnPublish=True
/p:Platform=AnyCPU /verbosity:diagnostic

The problem is that when I publish I get the following error, and my project’s files and directories strangely gets deleted

"D:\Blah\Blah\WCFService\WCFService.csproj" (_WPPCopyWebApplication;Publish target) (1) -> (_WPPCopyWebApplication target) -> C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(2516,5): error : Copying file obj\Dev\TransformWebConfig\trans formed\Web.config to D:\Blah\Blah\WCFService\Web.config failed. Could not find file 'obj\Dev\TransformWebConfig\ transformed\Web.config'. [D:\Blah\Blah\WCFService\WCFService.csproj]

0 Warning(s) 1 Error(s)

Could someone please show me the correct publish msbuild command that will properly create the zip file, and also Not delete my project’s code?

Upvotes: 1

Views: 1775

Answers (1)

crazyTech
crazyTech

Reputation: 1477

(Also, this still Will Not create a zip file, but it does publish properly, and will Not delete any project code files and directories)

It's kind of strange. I do Not know why but it's important to just invoke the MSBuild command by specifying the Visual Studio Publish Profile pubxml file that we can create using Visual Studio

In Visual Studio 2015,

  1. right-clicked on the project in question

  2. click on the "publish...." option

Go ahead and modify the configuration for the publish, and save the configuration, and there should be in the following directory:

C:\BlahBlah\BalhBlah\WCFService\Properties\PublishProfiles\

Just run the msbuild by specifying PublishProfile property with the value set to the Visual Studio Publish Profile pubxml file that

MSBuild.exe "C:\BlahBlah\BalhBlah\WCFService.csproj" /p:DeployOnBuild=true /p:PublishProfile="C:\BlahBlah\BalhBlah\WCFService\Properties\PublishProfiles\DEV.pubxml" /verbosity:diagnostic

Upvotes: 0

Related Questions