建立网站专案时,发布设定档无法运作 [英] Publish Profile not working when building website project

查看:266
本文介绍了建立网站专案时,发布设定档无法运作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认识到Visual Studio 2012不支持Web Deployment Projects.阅读

I recognized that Web Deployment Projects are not supported in Visual Studio 2012. After reading this article, I tried to get Publish Profiles to work.

安装 Visual Studio Web发布更新后,我能够使用新的发布来发布网站项目和Web应用程序项目Visual Studio 2012中的对话框.

After installing Visual Studio Web Publish Update I was able to publish web site projects and web application projects with the new publish dialog in Visual Studio 2012.

因为我们正在使用TFS 2010 Team Build,所以我尝试通过MSBuild参数使用发布配置文件.但是以下声明仅适用于发布Web应用程序项目.

Because we are using TFS 2010 Team Build I tried to use publish profile via MSBuild parameters. But the following statement only works to publish web application projects.

MSBuild.exe MyWebs.sln /p:Configuration=Release /p:DeployOnBuild=true;PublishProfile=DeployToDirectory.pubxml

如果我尝试发布网站项目,则不会发生任何事情.我的网站项目的发布配置文件仅适用于Visual Studio 2012中的新发布对话框,而不适用于调用MSBuild的情况.

If I try to publish website projects nothing happens. The publish profile of my website projects only works with the new publish dialog in Visual Studio 2012 but not when calling MSBuild.

有什么主意吗?

推荐答案

在我自己的环境中,我花了大约3周的时间来解决这个问题,并认为我有解决方案.

I have spent about 3 weeks wrestling with this in my own environment and think I have a solution.

我认为问题在于,当您传递解决方案时,从未真正构建website.publishproj文件.通过执行以下操作,我设法解决了这个问题:

I think the issue is that the website.publishproj file is never actually built when you pass in the solution. I managed to resolve this by doing the following:

  1. 请确保您使用的是新的ASP.Net和Tools 2012.2更新. 在此处下载.
  2. 在名为after.MyWebs.sln.targets的解决方案文件旁边创建一个文件.该文件应如下所示:

  1. Please make sure you are using the new ASP.Net and Tools 2012.2 update. Download Here.
  2. Create a file next to the solution file called after.MyWebs.sln.targets. This file should look as follows:

<!--?xml version="1.0" encoding="utf-8"?-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="Deploy Website" AfterTargets="Build">
        <Message Text="Starting Website deployment" Importance="high">
        </Message>
        <MSBuild Projects="$(MSBuildProjectDirectory)\MyWebs\website.publishproj" 
        BuildInParallel="true" /> 
    </Target>
</Project>

它的作用是,当MSBuild开始构建解决方案文件时,它实际上在内存中创建了扩展名为 metaproj 的MSBuild文件.有几种方法可以使MSBuild将文件保存到磁盘,以便您可以检查它,但可以在google上轻松找到它.在第一步中创建的文件被注入到 metaproj 文件中,并在构建后运行.

What this does is that when MSBuild starts building the solution file, it actually creates an MSBuild file in memory with the extension metaproj. There are ways to get MSBuild to save this file to disk so that you can inspect it but that is easily found on google. The file created in step one is injected into the metaproj file and is run after the build.

这是我可以获得新的发布配置文件"的唯一方法,可以为我提供以前使用旧的Web部署项目获得的输出.

This was the only way I could get the new Publish Profiles to give me the output that I used to get with the old Web Deployment Propjects.

警告语:如果要在TFS构建中使用它,则在这种情况下,您将在放置位置获得一个_PublishedWebsites文件夹,该文件夹与在pubxml文件中指定的PublishUrl无关. .这是我要解决的问题,但到目前为止,还没有太大的乐趣.

Word of warning: If you want to use this in a TFS build, then in this scenario, you will get a _PublishedWebsites folder in the drop location independent of the PublishUrl you specify in the pubxml file. This is something I am trying to resolve but so far, not having much joy.

这篇关于建立网站专案时,发布设定档无法运作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆