使用命令行发布的WCF服务(或ASP.NET Web应用程序)命令行、应用程序、WCF、ASP

2023-09-03 11:13:24 作者:倦了

我想模仿发布...从WCF服务项目(或ASP.NET Web应用程序或...)上下文菜单中的菜单项在Visual Studio 2008中,我没有必要把它发布到运行IIS的实例,只是把网页内容与bin文件夹上一些地方目录。有没有办法将其添加后生成的事件,或作为一个MSBuild任务?

I would like to simulate "Publish..." menu item from WCF Service project (or ASP.NET Web Application or...) context menu in Visual Studio 2008. I do not have a need to publish it to a running IIS instance, just to put the web content together with bin folder on some local dir. Is there any way to add it in post build events, or as a MSBuild task?

推荐答案

下面是答案,得益于此链接: http://codingcockerel.co.uk/2008/05/18/how-to-publish-a-web-site-with -msbuild / 所以,我刚才修改的Web应用程序中的.csproj文件,并写了这为AfterBuild目标(即已经在那里了):

Here is the answer, thanks to this link: http://codingcockerel.co.uk/2008/05/18/how-to-publish-a-web-site-with-msbuild/ So, I have just modified the .csproj file of web application, and wrote this into AfterBuild target (that was already there):

<Target Name="BeforeBuild">
    <Message Text="##############Before build##################" Importance="high"/>
    <RemoveDir Directories="publish"
        ContinueOnError="true"/>
</Target>
<Target Name="AfterBuild">
    <Message Text="##############After build##################$(OutputFolder)" Importance="high"/>
    <MSBuild Projects="$(ProjectName).csproj"
           Targets="ResolveReferences;_CopyWebApplication"
           Properties="WebProjectOutputDir=publish\;OutDir=publish\bin\" />
</Target>