0

I have Web API developed in C# and .Net framework 4.6.

I have hosted it on a server in IIS and it is working fine. Whenever there is any change, I change the code, do the testing and publish it.

The publishing is done manually till now. The process which we follow is, right click on API project, select Publish, select Publish Method as File System,Target Location as Some path on local machine, Configuration as Release and click on Publish button.It generates a set of files in the target location. I will copy those set of files on to the server.

Now I want to automate this process. So for this I'm writing commands to do this. So for building the application, I'm using MSBuild.exe.

MSBuild.exe ProjectName.sln /t:Rebuild /p:Configuration=Release

For publishing I have used this command :

dotnet.exe publish ProjectName.sln /p:configuration=Release

But when I run this publish command, it is giving :

Nothing to do. None of the projects specified contain packages to restore.

So I have following questions:

  1. Why is it trying to restoring packages when I'm trying to publish. I'm already restoring packages using another command before building --> Nuget.exe restore ProjectName.sln. So I do not want it to restore anything.
  2. Am I using the correct command to publish. If yes, how do I specify the target location?
halfer
  • 19,824
  • 17
  • 99
  • 186
CrazyCoder
  • 2,194
  • 10
  • 44
  • 91

1 Answers1

0

I assume you are not using .Net core. Hence dotnet command will not work.

The dotnet command line would work only with asp.net core projects.

Alternative :

Please refer this article which shows how to run web api2 project using command line:

Hope this helps.

Manoj Choudhari
  • 5,277
  • 2
  • 26
  • 37