Asp网络改变托管环境到开发

时间:2017-08-10 19:28:56

标签: asp.net asp.net-core

我正在尝试将我的asp.net核心托管环境更改为开发。 我已经做的是:

  1. 运行此命令:

    set ASPNETCORE_ENVIRONMENT=Development
    
  2. 更改系统中的环境变量:

    enter image description here

  3. 运行以下命令:

    dotnet restore
    
    dotnet watch run 
    
  4. 我只是在 projectName.csproj 文件中看到有评论说它运行生产,也许这就是问题所在。

    <Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Exec Command="npm install" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
    

    但是现在我在项目中看到的是托管环境:生产 我希望将其更改为环境,因为当我更改HTML,CSS等客户端更改时,我无法看到实时更改。

2 个答案:

答案 0 :(得分:1)

为系统设置ASPNETCORE_ENVIRONMENT变量后,必须先打开一个新的命令窗口,然后再运行dotnet run

环境变量在shell的生命周期内被缓存,因此现有窗口不会获取对环境变量的更改

我在这里写了一篇关于如何实现这个目标的帖子:https://andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/#atthecommandline

答案 1 :(得分:1)

要在Windows中设置ASPNETCORE_ENVIRONMENT环境变量,请在cmd中运行此命令:

"theme": "Seti.sublime-theme",
"caret_extra_width": 2,                 //  to have a wider/thicker caret
"caret_extra_bottom": 3,                //  to make the caret = to the line height (the theme currently support 0,3,5)
"caret_extra_top": 3,
"highlight_line": true,
"Seti_tabs_small": true,
"Seti_no_under_bar":true,
"Seti_yellow_tabclose": true,
"Seti_indigo_scrollbar": true,
"Seti_SB_med": true,
"Seti_sb_big_padding": true,
"Seti_bold_slctdfile_labels": true,
"Seti_sidebar_font_size_14": true,
"Seti_yellow_map": true,
"Seti_accent_lime": true,
"Seti_ClosedFolder_anim": true,
"Seti_teal_statusbar": true,
"Seti_panel_nrml": true,
"Seti_dark_fold_button": true,
"Seti_ClosedFolder_dots": true,
"Seti_sidebar_font_Fira": true,
"Seti_sidebar_font_Hack": true,
"Seti_bold_heading":true,              // make heading font in bold
"Seti_no_heading":true,                // remove the "folder,group 1,etc.."
"Seti_top_heading_big":true,           // sidebar top header img big
"Seti_top_heading_small":true,         // sidebar top header img small
"Seti_top_heading_anim" :true,          // sidebar top header img animate on hover
"Seti_alt_tree_row":true,      

或者

setx ASPNETCORE_ENVIRONMENT "Development" 中使用try:

web.config