5

I want to Publish my WCF Service Library using MSBuild Command Line with VS2012, i don't want to do right click->Publish Website , instead i want to publish it using Command Prompt(MSBuild).

What are the Pre-requisites required for MSBuild?

I don't have windows azure,it is necessary to install windows azure?

I am new to MSBuild, and I would like step by step instructions on how to accomplish this?

I want the .svc file, all the dll's inside the bin folder and web config file to be present inside the published folder.

Vaccano
  • 78,325
  • 149
  • 468
  • 850
Lokesh
  • 359
  • 1
  • 7
  • 17

3 Answers3

3

I found the answer for my question with the reference as below link, "http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment" using the command line "msbuild C:\ContosoUniversity\ContosoUniversity.sln /p:DeployOnBuild=true /p:PublishProfile=Test"

Lokesh
  • 359
  • 1
  • 7
  • 17
  • This solution does not work for WCF, there is no PublishProfile for WCF. Publish profiles exist only in Web applications not WCF. I did not yet found the solution for that. – Constantin Dec 07 '22 at 12:44
1

Your solution is fine and will work to deploy directly out to your host (don't forget to include your build Configuration so it publishes the correct config transform).

Another option is to "publish" your site to a local folder and then upload it to your host separately. This also gives you a chance to archive the site in a zip, do post checks and troubleshoot.

You can do this like so:

<MSBuild Projects="WebProject.csproj"
   Targets="Rebuild;_WPPCopyWebApplication"
   Properties="WebProjectOutputDir=WebProject\;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False;" />

If you get stuck there are more details on publishing WCF, ASP.NET and MVC projects.

Andrew dh
  • 881
  • 9
  • 19
  • I've read your helpful blog and had mixed success. One of my WCF projects keeps giving me the error, "error MSB4057: The target "_WPPCopyWebApplication" does not exist in the project." My csproj does not import Microsoft.WebApplication.targets. I tried adding that, but it didn't help. This was a legacy project that has been upgraded to VS2012 within the past year. Any advice would be appreciated. – Homr Zodyssey May 29 '14 at 20:25
  • Hard to say without seeing it, but you could try using $(MSBuildExtensionsPath32) instead of $(MSBuildExtensionsPath) – Andrew dh May 30 '14 at 03:21
  • I had copied the import statement from another csproj file. I realized it had a conditional on it that was not fulfilled. Once I removed that, I was able to use the _WPPCopyWebApplication target. However, now it doesn't generate the ".svc" file for my WCF service. – Homr Zodyssey May 30 '14 at 15:46
0

You can try with this.

The svc file was manually generated for first time use and then added to the project.

Content Include="*.svc" ---- Change this with the name of the file generated by VS Publish Option.

<ItemGroup>
  <Content Include="*.svc">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </Content>
</ItemGroup>
<ItemGroup>
  <WebConfig Include="App.config" />
</ItemGroup>
<Target Name="AfterBuild">
  <Copy SourceFiles="@(WebConfig)" DestinationFiles="$(OutDir)web.config" />
</Target>