Delforas
Delforas

Reputation: 81

MSbuild command won't create web deploy package but Visual Studio IDE can

I've tried several different commands and versions of MSBuild but I still can't generate a Web deploy package from it. I can, however, create one via Visual Studio 2017 using the same solution and pubxml file.

What I have tried:

I must be missing something in command line but I don't know what. Below are the commands I have tried:

/p:DeployOnBuild=true
/p:PublishProfile=<location of pubxml file>
/p:PackageLocation=<where to put zip>
/T:Package
/p:PackageAsSingleFile=true
/p:WebPublishMethod=Package

and various combinations of those with MSBuild versions from .Net 4.5, VS2017, and VS2015.

Upvotes: 1

Views: 4037

Answers (1)

Leo Liu
Leo Liu

Reputation: 76928

MSbuild command won't create web deploy package but Visual Studio IDE can

The type of project you are deploying should be the WebSite. The publish process of website project is not plumbed into the build process. When you create a publish profile in VS the following are created:

1) A publish profile (.pubxml file) under App_Data/PublishProfiles.

2) A website.publishproj in the root of the website.

The purpose of the website.publishproj is to facilitate command line publishing. So publish file should be website.publishproj rather than WebSite1.sln file. So the publish command line should be:

msbuild.exe "website.publishproj" /p:DeployOnBuild=true /p:PublishProfile=FolderProfile /p:PackageLocation="D:\LocalServer\web1.zip" /T:Package /p:PackageAsSingleFile=true /p:WebPublishMethod=Package

enter image description here

After that, you will noticed MSBuild created web deploy package to the PackageLocation:

enter image description here

Upvotes: 6

Related Questions