ASP。NET网站“发布”vs Web部署项目

时间:2023-01-17 09:21:58

if i decide to use the 'publish' option for my ASP.NET website, instead of a Web Deployment Project, can i do custom msbuild things? Or do i need to stick with WDP's if i want to do custom msbuild stuff during compile/deployment.

如果我决定为我的ASP使用“发布”选项。NET网站,而不是一个Web部署项目,我能做定制的msbuild东西吗?或者,如果我想在编译/部署期间做定制的msbuild工作,我需要继续使用WDP吗?

4 个解决方案

#1


4  

I think of the publish option as a part of the VS.NET toolset for developers to use to publish web sites on dev machines. It isn't really built to be a real deployment.

我认为发布选项是VS.NET工具集的一部分,开发人员可以使用它在开发机器上发布web站点。它并不是真正的部署。

If you need custom actions, a Web Deployment Project would be more suited to a real deployment that multiple people other than the developer run regularly and that you want created with each build.

如果您需要自定义操作,那么Web部署项目将更适合真正的部署,而不是由开发人员定期运行,并希望在每次构建中创建该部署。

I would also look at three other options:

我还要看另外三种选择:

  • PowerShell: A good way to script against IIS, set up websites, etc. You can even build cmdlets from OO code (like C#) that your script can call. Many professional IT firms use it to deploy big web sites.

    PowerShell:编写针对IIS的脚本、设置网站等等的好方法。您甚至可以从OO代码(如c#)构建cmdlet,您的脚本可以调用这些代码。许多专业的IT公司使用它来部署大型网站。

  • MSDeploy: A new deployment tool for websites that can replicate a vroot over several servers. Very good for having your golden image and then blasting it out to various places.

    MSDeploy:用于网站的新部署工具,它可以在多个服务器上复制vroot。非常适合拥有你的黄金形象,然后把它喷到不同的地方。

  • C# application: If you are a more advanced developer, you can always write your own application that xcopies files (via Process) and uses WMI to configure IIS. Harder, but you have complete control.

    c#应用程序:如果您是一个更高级的开发人员,您总是可以编写自己的应用程序来复制文件(通过进程)并使用WMI配置IIS。更难,但你有完全的控制权。

#2


2  

You can use custom MSBuild options. In fact, you can execute MSBuild on a sln file configured to publish as a website, and then copy the precompiled website files to a webserver. We do that internally using Cruise Control.net from Thoughtworks.

您可以使用定制的MSBuild选项。实际上,您可以在一个sln文件上执行MSBuild,该文件配置为作为一个网站发布,然后将预编译的网站文件复制到一个web服务器。我们在内部使用来自Thoughtworks的Cruise Control.net。

The sln file contains info about where the precompiled website will be located:

sln文件包含关于预编译网站的位置的信息:

Release.AspNetCompiler.VirtualPath = "/PrecompiledWeb"
Release.AspNetCompiler.PhysicalPath = "..\Web\"
Release.AspNetCompiler.TargetPath = "..\..\PrecompiledWeb\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "true"
Release.AspNetCompiler.Debug = "False"

#3


2  

We don't use publish to deploy our web projects, but we used to use Web Deployment Projects. When we switched to Visual Studio 2008, we ran into a bunch of problems with them, so we got rid of them.

我们不使用发布来部署我们的web项目,但是我们曾经使用web部署项目。当我们切换到Visual Studio 2008时,我们遇到了很多问题,所以我们把它们处理掉了。

What I can tell you is that we were able to replace the WDP functionality we were using with aspnet_merge.exe. We use a combination of msbuild and aspnet_merge.exe in a script to get our deployments done.

我可以告诉您的是,我们能够用aspnet_merge.exe替换我们使用的WDP功能。我们使用msbuild和aspnet_merge的组合。脚本中的exe以完成部署。

#4


1  

It looks like you can customize the Publish task through the _CopyWebApplication MSBuild target. Or you can at least create a batch file that will call that target, which you can customize.

看起来您可以通过_CopyWebApplication MSBuild目标定制发布任务。或者,您至少可以创建一个批处理文件,该文件将调用该目标,您可以自定义它。

More details here and here.

更多细节在这里和这里。

#1


4  

I think of the publish option as a part of the VS.NET toolset for developers to use to publish web sites on dev machines. It isn't really built to be a real deployment.

我认为发布选项是VS.NET工具集的一部分,开发人员可以使用它在开发机器上发布web站点。它并不是真正的部署。

If you need custom actions, a Web Deployment Project would be more suited to a real deployment that multiple people other than the developer run regularly and that you want created with each build.

如果您需要自定义操作,那么Web部署项目将更适合真正的部署,而不是由开发人员定期运行,并希望在每次构建中创建该部署。

I would also look at three other options:

我还要看另外三种选择:

  • PowerShell: A good way to script against IIS, set up websites, etc. You can even build cmdlets from OO code (like C#) that your script can call. Many professional IT firms use it to deploy big web sites.

    PowerShell:编写针对IIS的脚本、设置网站等等的好方法。您甚至可以从OO代码(如c#)构建cmdlet,您的脚本可以调用这些代码。许多专业的IT公司使用它来部署大型网站。

  • MSDeploy: A new deployment tool for websites that can replicate a vroot over several servers. Very good for having your golden image and then blasting it out to various places.

    MSDeploy:用于网站的新部署工具,它可以在多个服务器上复制vroot。非常适合拥有你的黄金形象,然后把它喷到不同的地方。

  • C# application: If you are a more advanced developer, you can always write your own application that xcopies files (via Process) and uses WMI to configure IIS. Harder, but you have complete control.

    c#应用程序:如果您是一个更高级的开发人员,您总是可以编写自己的应用程序来复制文件(通过进程)并使用WMI配置IIS。更难,但你有完全的控制权。

#2


2  

You can use custom MSBuild options. In fact, you can execute MSBuild on a sln file configured to publish as a website, and then copy the precompiled website files to a webserver. We do that internally using Cruise Control.net from Thoughtworks.

您可以使用定制的MSBuild选项。实际上,您可以在一个sln文件上执行MSBuild,该文件配置为作为一个网站发布,然后将预编译的网站文件复制到一个web服务器。我们在内部使用来自Thoughtworks的Cruise Control.net。

The sln file contains info about where the precompiled website will be located:

sln文件包含关于预编译网站的位置的信息:

Release.AspNetCompiler.VirtualPath = "/PrecompiledWeb"
Release.AspNetCompiler.PhysicalPath = "..\Web\"
Release.AspNetCompiler.TargetPath = "..\..\PrecompiledWeb\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "true"
Release.AspNetCompiler.Debug = "False"

#3


2  

We don't use publish to deploy our web projects, but we used to use Web Deployment Projects. When we switched to Visual Studio 2008, we ran into a bunch of problems with them, so we got rid of them.

我们不使用发布来部署我们的web项目,但是我们曾经使用web部署项目。当我们切换到Visual Studio 2008时,我们遇到了很多问题,所以我们把它们处理掉了。

What I can tell you is that we were able to replace the WDP functionality we were using with aspnet_merge.exe. We use a combination of msbuild and aspnet_merge.exe in a script to get our deployments done.

我可以告诉您的是,我们能够用aspnet_merge.exe替换我们使用的WDP功能。我们使用msbuild和aspnet_merge的组合。脚本中的exe以完成部署。

#4


1  

It looks like you can customize the Publish task through the _CopyWebApplication MSBuild target. Or you can at least create a batch file that will call that target, which you can customize.

看起来您可以通过_CopyWebApplication MSBuild目标定制发布任务。或者,您至少可以创建一个批处理文件,该文件将调用该目标,您可以自定义它。

More details here and here.

更多细节在这里和这里。