简体   繁体   English

Visual Studio 2015 .NET Core 1.0 自动构建

[英]Visual Studio 2015 .NET Core 1.0 Autobuild

I am working on a .NET Core 1.0 web application in Visual Studio 2015 Community.我正在 Visual Studio 2015 社区中开发 .NET Core 1.0 Web 应用程序。

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.显然有一个自动构建功能,我应该能够在没有调试的情况下运行( ctrl + F5 ),并且我对代码所做的任何更改都应该通过刷新页面来反映,但我无法使其正常工作。

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.我对视图所做的任何更改都会通过页面刷新反映出来,无论我是否在调试( F5ctrl + F5 )的情况下运行,但我对控制器或其他代码所做的任何更改都不是。

When I run with or without debugging, I get a command prompt that shows up.当我在调试或不调试的情况下运行时,我会得到一个显示的命令提示符。

在此处输入图片说明

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.' Projects\\MyProject\\bin\\Debug\\netcoreapp1.0\\ASPNET_Core_1_0.dll'用于写入--'进程无法访问文件'C:\\Users\\Adam\\Desktop\\Visual Studio Projects\\MyProject\\bin\\Debug\\netcoreapp1.0 \\ASPNET_Core_1_0.dll',因为它正被另一个进程使用。'

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.任何帮助将不胜感激。

I've noticed that if I run my application with IIS Express without debugging, I can get this autobuild function.我注意到,如果我在没有调试的情况下使用 IIS Express运行我的应用程序,我可以获得这个自动构建功能。 After I make some changes in my code, I can get that result by pressing F5 in the browser.在对代码进行一些更改后,我可以通过在浏览器中按F5来获得该结果。

However, if I run it directly using WebApplication as target, I cannot get this autobuild function.但是,如果我直接使用 WebApplication 作为目标运行它,则无法获得此自动构建功能。 I have to modify project.json as in the example below:我必须修改 project.json 如下例所示:

"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:我必须在profiles部分添加一些行到属性文件夹中的launchSettings.json:

"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"
      }
    }

将目标更改为 Dotnet Watch

After that, I can get this autobuild fuction by selecting dotnet watch as the target, with or without debugging.之后,我可以通过选择 dotnet watch 作为目标来获得这个自动构建功能,无论是否进行调试。 Thanks to asp.net core and Rehan Saeed .感谢asp.net coreRehan Saeed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM