Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure MSBuild to use a saved publishProfile for WebDeploy?

I have used Visual Studio to create a publish profile. It saved that information to MyProject.Publish.xml, located in the root of my project directory.

I would like the MSBuild task that gets executed on my CI server to use that file as its base settings. Ideally, if I could override properties via command line parameters, that would rock.

Is this possible? If so, what is the syntax?

For example, I'm looking for something like:

MSBuild MyProject.csproj /P:UsePublishProfile=True /P:UserName=deployUser /P:Password=MyPassword 
like image 891
Jim Geurts Avatar asked Feb 03 '11 18:02

Jim Geurts


People also ask

How do I install a Pubxml file?

In order to create a new profile once you have already defined one, you have to open the "Publish" window (righ click on the project), click on the "Profile" tab and select the <New...> option from the drop-down list; this will create a new pubxml file (see screenshot).

How do I Publish a Visual Studio solution from the command-line?

Basic command-line publishingThe default publish folder format is bin\Debug\{TARGET FRAMEWORK MONIKER}\publish\. For example, bin\Debug\netcoreapp2. 2\publish\. The dotnet publish command calls MSBuild, which invokes the Publish target.

Where are Pubxml files stored?

pubxml and are located in the PublishProfiles folder. The PublishProfiles folder is under Properties in a C# web application project, under My Project in a VB web application project, or under App_Data in a web site project.


1 Answers

I'm sorry to tell you that the publish.xml file which VS2010 uses was not designed to be used in this way. In fact it was not even designed to be checked-in/shared with others.

The logic for reading/writing those files are strictly contained inside Visual Studio and not available through MSBuild. So there is no straight forward way of doing this today. You have to pass in the individual property names/values when you call msbuild.exe. You can see a similar question that I answered at Team Build: Publish locally using MSDeploy for more info.

Note for VS 11 Developer Preview

Just so you know we have addressed this in the up coming version of Visual Studio. You can see if by downloading the VS 11 developer preview. Now all the profiles are saved into their own files (under the PublishProfiles in the Properties node in Solution Explorer). They are now designed to be checked in and shared with team members. These files are now MSBuild files and you can customize them if you wish. In order to publish from the command line just pass DeployOnBuild=true and set PublishProfile to the name of the profile. For example:

msbuild.exe MyProject.csproj /p:DeployOnBuild=true;PublishProfile=MyProfile 
like image 118
Sayed Ibrahim Hashimi Avatar answered Nov 07 '22 12:11

Sayed Ibrahim Hashimi