Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish WCF Service (or ASP.NET Web Application) using command line

Tags:

.net

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?

like image 237
Aleksandar Vucetic Avatar asked May 22 '09 15:05

Aleksandar Vucetic


People also ask

How do I publish a Visual Studio solution from the command line?

To deploy the app using a publish profile, execute the msbuild command from a Visual Studio Developer Command Prompt. The command prompt is available in the Visual Studio folder of the Start menu on the Windows taskbar. For easier access, you can add the command prompt to the Tools menu in Visual Studio.

How do I publish my asp net website locally?

On the computer where you have the ASP.NET project open in Visual Studio, right-click the project in Solution Explorer, and choose Publish. If you have previously configured any publishing profiles, the Publish pane appears. Click New or Create new profile. Select the option to import a profile.


1 Answers

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>
like image 69
Aleksandar Vucetic Avatar answered Oct 16 '22 22:10

Aleksandar Vucetic