Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link build configuration to a publish profile

Tags:

Why does Microsoft not allow you to link a build configuration to a publish profile. Instead it tells you to use the dropdown in the main VS interface.

Publish Dialog

I find this extremely annoying, because we use config transforms to change our config settings based on the environment we are publishing to (such as database connection strings). We also check-in the .Publish.xml file, so that the publish paths are saved in source control. If someone forgets to change the build configuration they could accidentally publish test to production or vice versa. If we could check in the build configuration selection with the publish profile we would not have this issue.

Does anyone know if Microsoft plans on changing this in the future?

like image 826
Billkamm Avatar asked Mar 23 '11 19:03

Billkamm


People also ask

What is publish profile in MSBuild?

Publish uses profiles (. pubxml files) to allow for multiple project configurations and multiple publish targets for a single project. The contents of the profile are XML and based on MSBuild. The Publish profile keeps credentials in a separate, hidden by default file that doesn't get checked-in.

How do I add a published profile to Visual Studio?

On the computer where you have the ASP.NET project open in Visual Studio, right-click the project in Solution Explorer, and choose Publish. If you have previously configured any publishing profiles, the Publish pane appears. Click New or Create new profile. Select the option to import a profile.

How do I change publish settings in Visual Studio 2017?

pubxml files and Visual Studio 2017 shows a list of file names in Publish toolbar. To change name of publish profile, you should change file name and then unload and reload project. Here are the steps to rename publish profile: Go to Solution Explorer → Project → Properties → PublishProfiles.


2 Answers

By pure luck, I found this:

http://blogs.msdn.com/b/webdev/archive/2012/06/15/visual-studio-2010-web-publish-updates.aspx

If you install this update (related to Azure), then the publishing tools are updated to a wizard type interface that DOES tie a publish profile to a specific build configuration.

I don't really understand why this is tied to Azure, but it works perfectly for all types of publishing (I use the publish to a folder option). No more publishing with the wrong build configuration!

like image 56
Ben Mills Avatar answered Jan 27 '23 10:01

Ben Mills


To get around this, you can write a batch script to do both parts of the process. Use MSBuild to build your projects in the required build configuration (we use release for our web apps). If all you need to do is copy the output, MSBuild should be able to do that for you as well with a copy task. If you need to deploy a web application, use MSDeploy command line tools to complete the publish command. Going command line with both of these tools opens up a lot of customization.

like image 24
Justin Beckwith Avatar answered Jan 27 '23 09:01

Justin Beckwith