Reputation: 1477
We have an solution developed using the following technologies:
Visual Studio 2015
.NET Framework 4.8
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
clean
build
publish (specifically want to publish to a zip file, and here is where the process gives a problem )
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
Start to Run Dos Command Prompt in Administrator Mode
Let’s clean the project
D:\Blah\Blah\WCFService>"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:Clean
D:\Blah\Blah\WCFService>" C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:Build /p:Configuration=Dev
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
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,
right-clicked on the project in question
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