Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish profiles don't publish the desired build configuration (.pubxml.user)

Consider the following scenario:

  • Alice creates Web application (ASP.NET MVC or WebForms) using Visual Studio 2012.
  • Alice creates a Publish Profile called "PRODUCTION" and chooses "Release" configuration in the Settings tab (in the Publish Wizard).
  • Alice publishes the application using the Publish Profile called "PRODUCTION".
  • Alice saves the solution into source control.

Note that by default the "*.pubxml.user" file is not included in source control: http://msdn.microsoft.com/en-us/library/ff398069.aspx

  • Bob does a Checkout of the solution from the source control.
  • Bob opens the solution and launches the Publish Wizard.
  • Bob sees the selected Publish Profile is called "PRODUCTION".
  • Bob clicks on Settings tab (in the Publish Wizard) and sees the displayed configuration is "Release".
  • Bob publishes the application.
  • Bob realizes the application was published using "Debug" configuration instead of "Release" configuration.

The reason is the information about the build configuration is stored in the file "*.pubxml.user" (See node called <LastUsedBuildConfiguration>).

This behavior is problematic especially when you use Web config transformations ("Web.Release.config") to change connection strings.

=> How can I fix this problem if I don't want to save "*.pubxml.user" file into source control (because this file can contains other information inappropriate for a public repository for example)?

Related articles:

  • http://connect.microsoft.com/VisualStudio/feedback/details/776066/publish-settings-windows-azure-publish-target-profiles-not-selecting-proper-build-configuration
  • http://sedodream.com/2012/10/27/MSBuildHowToSetTheConfigurationProperty.aspx
  • http://msdn.microsoft.com/en-us/library/dd465337.aspx
like image 434
Jonas at Software Journey Avatar asked Mar 21 '13 16:03

Jonas at Software Journey


1 Answers

There are two aspects to this; sharing the value in the drop down for the Publish dialog and support for command line. Below are my comments on both.

Sharing profiles with team members

When we released the publish bits in VS2012 RTM we were writing LastUseBuildConfiguraiton into the .pubxml.user file. We have since moved that to the .pubxml file itself so that it is shared with other team members. You can get the latest build at:

  1. ASP.NET 2012.2
  2. Latest Azure SDK

If you have installed one of those and you are still seeing the behavior where the Config is not shared that is likely because the .pubxml was created with an older drop. The solution is to delete the .pubxml and .pubxml.user file and create it again with the latest.

Command line scenarios

For command line scenarios the Configuration property needs to be set explicitly. The .pubxml (or .pubxml.user) file cannot override that value. For more details see my blog at http://sedodream.com/2012/10/27/MSBuildHowToSetTheConfigurationProperty.aspx.

like image 158
Sayed Ibrahim Hashimi Avatar answered Nov 13 '22 06:11

Sayed Ibrahim Hashimi