How to use command line msbuild to deploy VS2012 Web Site project without precompiling it?

后端 未结 2 1810
小鲜肉
小鲜肉 2020-11-30 22:50

I\'ve inherited a very large VS2012 web site project (not web application) and am trying to automate it\'s deployment. There are tons of circular references in the project s

相关标签:
2条回答
  • 2020-11-30 22:59

    For website project the publish process is not plumbed into the build process. For website project since there is no formal build process there was nothing for us to really extend.

    Note: the below contents requires to have VS 2012 (or VS2010 for that matter) and the Azure SDK on top of that. The features were not included in the RTM drop of VS2012.

    After creating 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. It is a fill in for the .csproj/.vbproj which you would normally get when using a Web App Project.

    If you would like to automate publishing you can use a command like the following.

    msbuild.exe website.publishproj /p:DeployOnBuild=true 
       /p:PublishProfile=<profile-name-no-extension> /p:VisualStudioVersion=11.0
    

    You should not have to specify which targets invoked.

    Regarding the message in VS that the site is being pre-compiled, that is a bug. It runs through a pre-compile but the publish uses the setting in the profile. That bug should have been fixed in Visual Studio Update 1. After installing that you should not see the un-necessary pre-compile step. Please let me know if you still do see that.

    0 讨论(0)
  • 2020-11-30 23:17

    While Sayed Ibrahim Hashimi's answer did help me somewhat, here is what I found to be neccessary for VS2012:

    After installing the Azure SDK, I created a file publish profile, which created a PublishProfiles folder in the Properties folder of my project. Inside this new folder, two xml files named my_sample_PublishProfile_Foo.pubxml and my_sample_PublishProfile_Foo.pubxml.user where created.

    Using the .pubxml, I am able to publish with msbuild like this:

    c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "C:\...\UI.csproj" /p:DeployOnBuild=true /p:PublishProfile="C:\...\PublishProfiles\my_sample_PublishProfile_Foo.pubxml"  /p:VisualStudioVersion=11.0
    

    Remember to run the batch file that contains this script with Administrator privileges.

    0 讨论(0)
提交回复
热议问题