当我构建 ASP.NET Web 应用程序时,我得到一个包含代码的 .dll 文件对于其中的网站(这很棒),但该网站还需要所有 .aspx 文件和朋友,并且这些文件需要放置在正确的目录结构中。 我怎样才能将这一切作为每次构建的结果放在一个目录中? 尝试从源目录中选择正确的文件是一件痛苦的事情。
最终结果应该是 xcopy 可部署的。
更新:我不想手动使用我所知道的“发布”命令。 我希望应用程序所需的全套文件成为构建输出 - 这意味着我还可以通过运行 MSBuild。
When I build my ASP.NET web application I get a .dll file with the code for the website in it (which is great) but the website also needs all the .aspx files and friends, and these need to be placed in the correct directory structure. How can I get this all in one directory as the result of each build? Trying to pick the right files out of the source directory is a pain.
The end result should be xcopy deployable.
Update: I don't want to have to manually use the Publish command which I'm aware of. I want the full set of files required by the application to be the build output - this means I also get the full set of files in one place from running MSBuild.
发布评论
评论(9)
您是否尝试过使用 .net Framework 目录中的 aspnet_compiler.exe ? 我非常确定您可以创建 Web 应用程序或网站的“部署就绪”版本。
Have you tried using the aspnet_compiler.exe in your .net framework directory? I'm pretty sure you can create a "deploy ready" version of a web application or web site.
MSBuild 上的 _CopyWebApplication 目标将完全满足您的需要。 问题是只有主程序集会被复制到 bin 文件夹,这就是为什么需要复制任务来复制 bin 文件夹上的任何其他文件。
我试图将示例脚本作为本文的一部分发布,但未能成功。
请看一下这个文章 介绍了如何创建与您需要的类似的 MSBuild 脚本。
The _CopyWebApplication target on MSBuild will do exactly what you need. The catch is that only the main assembly will be copied to the bin folder and that's why a copy task is needed to also copy any other file on the bin folder.
I was trying to post the sample script as part of this post but wasn't able to.
Please take a look at this article on my blog that describes how to create a MSBuild script similar to the one you need.
ASP.NET 没有为新站点提供真正的 xcopy 部署。 这取决于 IIS 中是否有虚拟目录/应用程序。 但是,创建虚拟目录后,您可以使用 xcopy 进行更新。
ASP.NET doesn't have real xcopy deployment for new sites. It depends on having a virtual directory/Application in IIS. However, once that virtual directory is created you can use xcopy for updates.
您可以发布网站..如果您想要自动化部署,您需要使用一些脚本。
You can Publish Web site..If you want to automate your deployment, you need to use some script.
一种解决方案是 Web 部署项目 (WDP),它是 Visual Studio(和 msbuild)的一个附加组件,可将 Web 项目构建到目录中,并且可以选择合并程序集并更改 web.config 文件。 构建 WDP 的输出是在一个目录中部署站点所需的所有文件。
有关 Web 部署项目的详细信息:
此解决方案的唯一缺点是需要一个必须在构建计算机上可用的附加组件。 不过,目前来说已经足够了!
One solution appears to be Web Deployment Projects (WDPs), an add-on for Visual Studio (and msbuild) available that builds a web project to a directory and can optionally merge assemblies and alter the web.config file. The output of building a WDP is all the files necessary to deploy the site in one directory.
More information about Web Deployment Projects:
The only disadvantage to this solution is the requirement on an add-on which must be available on the build machine. Still, it's good enough for now!
您是否尝试过在解决方案资源管理器中右键单击该网站并单击“发布网站”?
Have you tried right clicking the website in Solution Explorer and clicking 'Publish Website'?
构建--> 发布
将出现一个对话框,指导您完成该过程。
Build --> Publish
A dialog box will appear that will guide you through the process.
对于您在更新中描述的自动构建,我建议您查看 MSBuild< /a> 和 CruiseControl.NET
For the automated building you describe in the update, I would recommend you look into MSBuild and CruiseControl.NET
这取决于您需要多复杂的解决方案,例如您可以仅使用脚本和詹金斯。 您可以将 MSBUild 与 Jenkins 结合使用,仅部署到 IIS。 如果您有 Jenkins,以后可以很容易地连接其他工具。 但如果您只想构建,请使用一个脚本,让 jenins 执行每个使用 MSDeploy 的构建,这样效果会很好。
我就是这样做的,只是为了给您一种感觉:
Sonarqube 使用 Gallio、Gendarme、FXcop、Stylecop、NDepths 和 PartCover 来获取您的指标,所有这些都非常简单,因为 SonarQube 会自动执行此操作,无需太多配置。
这是 Jenkins 女巫构建并获取 Sonar 指标以及自动部署到 IIS 的另一项工作。 我使用一个简单的脚本一行来调用我的 MSBuild 和 URL、pass 和用户。
还有 Sonarqube,我的项目的所有指标。 这是一个简单的 MVC4 应用程序,但效果很好!:
如果您需要更多信息,我可以为您提供一个很好的指南。
整个设置使用 MSBuild,也构建和部署应用程序。
It depends on how complicated solution you need, you could just use a script and jenkins for example. You can use MSBUild with Jenkins for just deploying to an IIS. And if you got Jenkins other tools is pretty easy to connect into it later on. But if you just want to build, use a script that jenins execute every build that uses MSDeploy and it will work great.
This is how i do it, just to give you a feeling:
Sonarqube uses Gallio, Gendarme, FXcop, Stylecop, NDepths and PartCover to get your metrics and all this is pretty straight forward since SonarQube do this automatically without much configuration.
Here is Jenkins witch builds and get Sonar metrics and a another job for deploying automatically to IIS. I use a simple script one line that calls my MSBuild and wich URL, pass and user.
And Sonarqube, all metrics for my project. This is a simple MVC4 app, but it works great!:
If you want more information can i provide you with a good guide.
This whole setup uses MSBuild, too build and deploy the apps.