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

2

9

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:

Berwick answered 21/3, 2013 at 16:41 Comment(0)
L
11

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.

Lothaire answered 21/3, 2013 at 19:4 Comment(1)
Thanks. Installing "ASP.NET 2012.2" fixed the problem. Now the property "LastUsedBuildConfiguration" is stored in ".pubxml" (instead of ".pubml.user").Berwick
P
0

If you have a backup of this Project then no need to worry about this error. Just run the backup project in VS 2012 OR 2013 and open the node of Property and then publish Profile folder and the then you will see there a single file with name of "Your project name.xml" now go to solution explorer menu press the button of "show all files" and you can see an other file with the name of "pubxml.user". Now right click on the publish Profile and click the option "open folder in file explorer" now copy the file and replace it with crashed file.

Now rebuild project and after that publish it.

I was getting this problem today with this project Hajj and Umrah Project now you can see that is live.

Photogrammetry answered 24/6, 2015 at 20:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.