dotnet/vscode-csharp

ignore or Specify Properties/launchSettings.json setting

rcl4444 opened this issue · 11 comments

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.505     
 Commit:    b220231234  

Runtime Environment:    
 OS Name:     Windows   
 OS Version:  10.0.18362
 OS Platform: Windows   
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.505\

Host (useful for support):
  Version: 2.1.9
  Commit:  dcedc87d22

.NET Core SDKs installed:
  2.1.505 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

VS Code version:

Version: 1.35.1 (user setup)
Commit: c7d83e57cd18f18026a8162d042843bda1bcf21f
Date: 2019-06-12T14:30:02.622Z
Electron: 3.1.8
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.18362

C# Extension version:

Name: C#
Id: ms-vscode.csharp
Description: C# for Visual Studio Code (powered by OmniSharp).
Version: 1.20.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

Steps to reproduce

.vscode/launch.json‘s setting below:

        {
            "name": "SplitPackageWeb",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "buildWebHost",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/aspnet-core/src/SplitPackage.Web.Host/bin/Debug/netcoreapp2.1/SplitPackage.Web.Host.dll",
            "args": [],
            "cwd": "${workspaceFolder}/aspnet-core/src/SplitPackage.Web.Host",
            "stopAtEntry": false,
            "launchBrowser": {
                "enabled": true
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "ASPNETCORE_URLS": "http://+:8070",
                "ConsulConfig__IsRegister": "false"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        }

my host project Properties/launchSettings.json‘s setting below:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:8070/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchUrl": "http://localhost:8070",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ConnectionStrings__Default": "Server=127.0.0.1; port=3307; Database=SplitPackageDb; uid=root; pwd=root; Convert Zero Datetime=True"
      }
    },
    "SplitPackage.Web.Host_local": {
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_URLS": "http://+:8070",
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ConnectionStrings__Default": "Server=127.0.0.1; port=3307; Database=SplitPackageDb; uid=root; pwd=root; Convert Zero Datetime=True"
      }
    },
    "IIS Express_Test": {
      "commandName": "IISExpress",
      "launchUrl": "http://localhost:8070",
      "environmentVariables": {
        "ConnectionStrings__Default": "Server=192.168.1.230; port=3306; Database=SplitPackageDb; uid=root; pwd=Qjkj2018; Convert Zero Datetime=True",
        "ASPNETCORE_ENVIRONMENT": "Test"
      }
    },
    "SplitPackage.Web.Host_Test": {
      "commandName": "Project",
      "environmentVariables": {
        "ConnectionStrings__Default": "Server=192.168.1.230; port=3306; Database=SplitPackageDb; uid=root; pwd=Qjkj2018; Convert Zero Datetime=True",
        "ASPNETCORE_URLS": "http://+:8070",
        "ASPNETCORE_ENVIRONMENT": "Test"
      }
    }
  }
}

Expected behavior

Project uses environment variables to change application configuration.when I start debug app, I hope the Properties/launchSettings.json setting can't not be use, because my colleagues use multiple configurations to distinguish between local and test environments on VS2017. there are two project setting in the profiles node. I can ignore Properties/launchSettings.json setting or Specify which configuration to use?

Actual behavior

Properties/launchSettings.json's node SplitPackage.Web.Host_local is applied.

To make sure I understand the request: you would like a launch.json setting to explicitly indicate a launchSettings.json profile, and if specified, environment variables from the lauchSettings profile would trump even launch.json. Do I have that correct?

Yes.This distinguishes the impact of VS configuration.

Is this in the pipeline, or is there some other approach that might resolve the following?

Working together where some are using VS and others VSCode, we have our local run options defined via various profiles in Properties/launchSettings.json.
Debugging in VS has the option of picking one of the profiles via a dropdown.
When running via dotnet run I can supply the --launch-profile parameter specifying the profile in launchSettings.json that I want to use - or leave it out and go with the top one.
Debugging in VSCode, however, I'd assumed that I could add the --launch-profile as args in launch.json - which does not work, it just always picks the top one.

I'm really missing the ability to be able to specificy --launch-profile for a launch.json configuration, or being presented with a profile picker (similar to command:PickProcess).

This is annoying when used in combination with docker-compose. I don't want dotnet watch run to use launch config that I have for my editor.

Recognized the behaviour which @MikaelElkiaer described today when opening a vs2019 project in vs code. Colleagues are using launchSettings.json to have env variable sets for different environments & a local debug stack. If ran in VScode, the first profile is used.
Best solution to this would be:
Be able to specify the launchSettings.json profile to use for a vscode launch configuration

But I'd also be fine with an Option to fully ignore the launchSettings.json (so I would be able to create the profiles I need myself in launch.json)

My current workaround:
Deleting the launchSettings.json in my local copy and taking care I do not commit that deletion ...

I am in the same world here, have a webpack proxy setup as part of a launchSetting.json profile and want to be fit to debug as part of VSCode with cross team on VS and VS code. Is there any update on this feature

+1

@gregg-miskelly

版本: 1.51.1 (system setup)
提交: e5a624b788d92b8d34d1392e4c4d9789406efe8f
日期: 2020-11-10T23:34:32.027Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.17763

I see omnisharp-vscode ignore Properties/launchSettings.json config.it 's new feture in omnisharp-vscode?

Recognized the behaviour which @MikaelElkiaer described today when opening a vs2019 project in vs code. Colleagues are using launchSettings.json to have env variable sets for different environments & a local debug stack. If ran in VScode, the first profile is used.
Best solution to this would be:
Be able to specify the launchSettings.json profile to use for a vscode launch configuration

But I'd also be fine with an Option to fully ignore the launchSettings.json (so I would be able to create the profiles I need myself in launch.json)

My current workaround:
Deleting the launchSettings.json in my local copy and taking care I do not commit that deletion ...

Have you tried to edit launch.json by adding --launch-profile "SampleApp" to args section?
In this case will it regard to the launch profile?

@Smoovsky that would not work. That is just going to pass that arg to your app.

Any news on this? My team is a mixed environment when some people use VS 2019 and others use VSCode + devcontainers, which requires differences in some environment variables. Having the ability to ignore launchSettings.json files in VSCode would help a lot