2

I am working on a .NET Core 1.0 web application in Visual Studio 2015 Community.

Apparently there is an autobuild function, where I should be able to run without debugging (ctrl+F5) and any changes I make to my code should be reflected simply by refreshing the page, but I cannot get this working.

Any changes I make to my views is reflected with a page refresh regardless of whether or not I am running with or without debugging (F5 or ctrl+F5), but any changes I make to controllers or other code is not.

When I run with or without debugging, I get a command prompt that shows up.

enter image description here

If I run the project without debugging and then try and build, I get the following error

Projects\MyProject\bin\Debug\netcoreapp1.0\ASPNET_Core_1_0.dll' for writing -- 'The process cannot access the file 'C:\Users\Adam\Desktop\Visual Studio Projects\MyProject\bin\Debug\netcoreapp1.0\ASPNET_Core_1_0.dll' because it is being used by another process.'

So if I run a project without debugging, I need to close this command prompt, and then re-run with or without debugging to see the changes.

Any help would be greatly appreciated.

Eriawan Kusumawardhono
  • 4,796
  • 4
  • 46
  • 49
user3012633
  • 464
  • 5
  • 6
  • I don't think there is IDE integration yet, https://docs.asp.net/en/latest/tutorials/dotnet-watch.html – Lex Li Oct 17 '16 at 01:05
  • @user3012633, any update? Would you please let us know that latest information about this issue? Whether the dotnet watch is helpful for you? – Jack Zhai Oct 20 '16 at 01:55

1 Answers1

2

I've noticed that if I run my application with IIS Express without debugging, I can get this autobuild function. After I make some changes in my code, I can get that result by pressing F5 in the browser.

However, if I run it directly using WebApplication as target, I cannot get this autobuild function. I have to modify project.json as in the example below:

"tools": {
  "Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"
},

And I have to add some lines in the profiles section to launchSettings.json in the Properties folder:

"dotnet watch": {
      "executablePath": "C:\\Program Files\\dotnet\\dotnet.exe",
      "commandLineArgs": "watch run --server.urls http://*:5000",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }

Changing the target to Dotnet Watch

After that, I can get this autobuild fuction by selecting dotnet watch as the target, with or without debugging. Thanks to asp.net core and Rehan Saeed.

  • Thanks for this answer. I was doing an on-line class and I was annoyed that it would not auto-build for me like it would for the instructor. I think I missed the fact that he was starting without the debugger. – GlennSills Dec 02 '16 at 15:37