How to publish ASP.NET Web API without Visual Studio?

15,361

Solution 1

There are a number of publishing mechanisms you can look into to publish your website without Visual Studio. Out of the box you can take advantage of Publish Profiles, it sounds like you've already used this to publish locally, you can extend this to publish using Web Deploy or FTP - both require additional services to be setup on your web server though.

Web Deploy: http://www.iis.net/downloads/microsoft/web-deploy

How to: Deploy a Web Project Using One-Click Publish in Visual Studio: http://msdn.microsoft.com/en-us/library/dd465337(v=vs.110).aspx

Once you've chosen a publish mechanism to use, you can execute the following command to build & publish, without Visual Studio:

msbuild MyProject.sln /p:DeployOnBuild=true /p:PublishProfile=ProfileName

** NOTE: Long term, I'd recommend you build and deploy your project on a build server. The above is OK for a proof of concept or none-important projects.

Solution 2

I simply use Publish with File System, then all of the API files will be output to the Target Location, and I copy these files to any IIS Website physical folder on local or on other Server, the API can work after restart that IIS Website.

enter image description here

Solution 3

Building upon the great ideas presented by Tom above, you could also create a Deployment Package from Visual Studio, upload the ZIP to the destination server, then manually install it there via IIS Manager. The process is documented for .NET 4.5 at https://msdn.microsoft.com/en-us/library/dd465323(v=vs.110).aspx.

This allows you to separate the build and deploy steps, which is something I needed for my use case so that system admins can deploy my Web API app to new servers without needing to be conversant in msbuild or Visual Studio. :)

Share:
15,361
Admin
Author by

Admin

Updated on June 14, 2022

Comments

  • Admin
    Admin almost 2 years

    How can I publish ASP.NET Web API without Visual Studio?

    There is an external server, where must be only binaries or created project.

    If I publish with the studio on localhost to the local IIS - no problem. But I need now publish it to the remote Windows server, where there isn't any Visual Studio, just IIS and RDP access.

    I have tried to create a new web site from IIS management tool, assign the classic AppPool, assign new website to physical path, copy files from dev PC to that path.

    And it just doesn't work and doesn't show any errors... How can I solve this problem?

  • Click Ok
    Click Ok over 7 years
    Great answer, Tom. Can you provide some resource to learn about build servers?
  • Tom Hall
    Tom Hall over 7 years
    @ClickOk, personally, I've had a lot of success with Atlassian Bamboo and ThoughtWorks Go, and for automated deployments, Octopus Deploy.