将网站部署包构建为构建后事件
我正在使用 Visual Studio 2010。我有一个网站项目,我想在每次构建项目时构建一个网站部署包。基本上,我正在寻找构建后 MSBuild 命令的一些示例,该命令基本上与网站右键菜单中的“构建部署包”选项执行相同的操作。
I am using visual studio 2010. I have a website project that I would like to build a website deployment package every time I build a the project. Basically I am looking for some example of a post build MSBuild command that will basically do the same thing as the "Build Deployment Package" option from the right click menu of the website.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您正在使用 Web 应用程序项目,因为网站项目没有“构建部署包”。
我建议不要在每个构建上执行包,因为这会大大减慢您的开发速度。话虽这么说,你可以在这里做到这一点。
如果您确实想要执行此操作,那么最好的选择不是使用构建后事件,而是编辑项目文件并扩展构建过程。为此,请打开您网站的 .csproj 文件,然后在底部(在导入元素之后)放置以下内容。
这样做的作用是扩展构建过程以调用包 目标。这与在 Visual Studio 中调用“构建部署包”目标时调用的目标相同。
I assume you are using Web Application Projects, because Web Site projects do not have the "Build Deployment Package".
I would recommend not performing a package on every build, because it will slow down your development drastically. With that being said, you can do it here is how.
If you really wanted to do this your best bet is not to use post-build event, but to edit the project file and extend the build process. To do this open the .csproj file for your web and then towards the bottom (after the Import elements) place the following
What this does is extend the build process to call the Package target. This is the same target that is called when you invoke the "Build Deployment Package" target in Visual Studio.
对我来说,Sayed 的答案不适用于命令行 msbuild 执行(我需要
Publish target,但思路是一样的):
我无法使用
DefaultTargets
因为我想在命令行上发布但只能从 VS 构建。这是有效的:For me, Sayed's answer didn't work with a command-line msbuild execution (I needed the
Publish
target, but the idea is the same):I couldn't use
DefaultTargets
because I wanted to publish on the command-line but only build from VS. Here's what did work: