且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将解决方案升级到 .NET 框架 4.5 后,日常部署停止工作

更新时间:2023-10-05 12:56:28

这是我的建议.在 VS2012 中,我们可以使用发布对话框创建的发布配置文件轻松自动发布您的 Web 项目.在您的情况下,创建一个新的 MSDeploy 配置文件.当您创建该配置文件时,我们会将设置保存到 PropertiesPublishProfiles(或 VB 的 My ProjectPublishProfiles)下的文件中.此文件的扩展名为 .pubxml.这些文件实际上是 MSBuild 文件,您可以根据需要对其进行自定义.您也可以继续使用发布对话框.密码将存储在 .user 文件中并进行加密,以便只有您可以解密.

Here is what I would recommend. In VS2012 we have made it easy to automate publishing your web projects using the publish profiles which are created by the publish dialog. In your case create a new MSDeploy profile. When you create that profile we will save the settings into a file under PropertiesPublishProfiles (or My ProjectPublishProfiles for VB). The extension of this file will be .pubxml. Those files are actually MSBuild files, which you can customize if needed. You can continue to use the publish dialog as well. The password will be stored in a .user file and encrypted such that only you can decrypt it.

创建该配置文件后,如果您正在构建 .sln 文件,则可以使用以下命令进行发布.

After you have created that profile you can publish with the command below if you are building the .sln file.

msbuild mysoln.sln /p:DeployOnBuild=true /p:PublishProfile=<ProfileName> /p:Password=<Password>

如果您正在构建 .csproj/.vbproj,那么您需要通过以下方式对其进行一些调整

If you are building the .csproj/.vbproj then you need to tweak this a bit in the following way

msbuild mysoln.sln /p:DeployOnBuild=true /p:PublishProfile=<ProfileName> /p:Password=<Password> /p:VisualStudioVersion=11.0

更多关于为什么需要 VisualStudioVersion 的信息,请访问 http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx.

More on why VisualStudioVersion is required at http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx.

完成此操作后,您将能够像以前一样构建+发布.仅供参考,我们已经在 Azure SDK https:/中为 VS2010 提供了所有这些新的网络发布功能/www.windowsazure.com/en-us/develop/net/#.

Once you do this you will be able to build+publish just like you did previously. FYI we have shipped all these new web publish features for VS2010 in the Azure SDK https://www.windowsazure.com/en-us/develop/net/#.

也在您的问题中,我注意到您指定了一些自定义属性,例如 MvcBuildViews.如果需要,您现在可以将这些属性直接放在发布配置文件(.pubxml 文件)中.当然,如果这对您的场景更有意义,您仍然可以在命令行中传递它们.

Also in your question I noticed that you are specifying some custom properties, like MvcBuildViews. You can now place those properties directly inside the publish profile (the .pubxml file) if you want. Of course you can still pass them in on the command line if that makes more sense for your scenario.

有关此的更多信息 http://sedodream.com/2012/06/15/VisualStudio2010WebPublishUpdates.aspx.

如果您看看我们为开发人员提供的自动发布方法,那就是指定要在构建期间执行的属性和目标.这种方法的问题在于,这限制了我们增强网络发布体验的能力.在新版本中,我们引入了一个抽象,即发布配置文件,它允许我们更改 Web 发布管道的底层目标,并且您的自动化脚本将继续运行.希望从现在开始,您不必重新访问此问题.

If you take a look at the approach that we had for developers to automate publishing it was to specify properties and targets to be executed during the build. The problem with this approach is that this limits our ability to enhance the web publish experience. In the new release we have introduced an abstraction, the publish profile, which allows us to change the underlying targets of the web publish pipeline and your automation scripts will continue to run. Hopefully from this point forward you will not have to re-visit this issue.