12

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?

3 Answers 3

9

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>
Sign up to request clarification or add additional context in comments.

Comments

0

You should be able to write an xcopy command to copy the files you need to the right location. Microsoft has an article about xcopy deployment for asp.net.

Once you have the command right you can put it into the Post Build actions so it automatically fires after a build.

Also see VS Post Build Event for examples on copying just the dll output (note the use of $(TargetPath) & $(TargetDir)).

Comments

0

HI, You should take a look at Web Deployment Projects. These are actually MSBuild files with Visual Studio GUI support. They will pre-compile your site. You can extend the behavior of these to copy the generated files to your web server.

Sayed Ibrahim Hashimi

My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build

1 Comment

I'm having problems with Web Deployment Projects, since they deploy the .csproj file, obj folder and all the other unnecessary stuff. I would just like to reproduce the bahavior of "Publish..." command from the context menu of Web Application (not Web Site) project. Is there some easier way, or I have to exclude them manually, just like with the xcopy?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.