Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore or Specify Properties/launchSettings.json setting #3121

Closed
rcl4444 opened this issue Jun 16, 2019 · 11 comments
Closed

ignore or Specify Properties/launchSettings.json setting #3121

rcl4444 opened this issue Jun 16, 2019 · 11 comments

Comments

@rcl4444
Copy link

rcl4444 commented Jun 16, 2019

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.

@gregg-miskelly
Copy link
Contributor

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?

@rcl4444
Copy link
Author

rcl4444 commented Jun 18, 2019

Yes.This distinguishes the impact of VS configuration.

@MikaelElkiaer
Copy link

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).

@MaikuMori
Copy link

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.

@oldluke92
Copy link

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 ...

@Michael-IRL
Copy link

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

@kmute90
Copy link

kmute90 commented Nov 20, 2020

+1

@rcl4444
Copy link
Author

rcl4444 commented Nov 24, 2020

@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?

@Smoovsky
Copy link

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?

@gregg-miskelly
Copy link
Contributor

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

@kipters
Copy link

kipters commented Jun 1, 2021

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

@gregg-miskelly gregg-miskelly self-assigned this Sep 18, 2021
gregg-miskelly added a commit to gregg-miskelly/vscode-csharp that referenced this issue Oct 28, 2021
This PR updates the debugger to 1.23.17. This includes:
* All the bug fixes that went into Visual Studio 17 GA
* Updating the debugger to run on .NET 6 RC2
* Enhanced support for launchSettings.json ([dotnet#3121](dotnet#3121))
* Now that most users will not need to download the debugger themselves (it comes pre-packaged in a platform specific), this changes back to the Azure CDN instead of https://download.visualstudio.microsoft.com

This also updates `gulp updatePackageDependencies` to support updating packages when the primary URL just has a simple version number.
gregg-miskelly added a commit to gregg-miskelly/vscode-csharp that referenced this issue Oct 28, 2021
This PR updates the debugger to 1.23.17. This includes:
* All the bug fixes that went into Visual Studio 17 GA
* Updating the debugger to run on .NET 6 RC2
* Enhanced support for launchSettings.json ([dotnet#3121](dotnet#3121))
* Now that most users will not need to download the debugger themselves (it comes pre-packaged in a platform specific), this changes back to the Azure CDN instead of https://download.visualstudio.microsoft.com

This also updates `gulp updatePackageDependencies` to support updating packages when the primary URL just has a simple version number.
gregg-miskelly added a commit that referenced this issue Oct 28, 2021
This PR updates the debugger to 1.23.17. This includes:
* All the bug fixes that went into Visual Studio 17 GA
* Updating the debugger to run on .NET 6 RC2
* Enhanced support for launchSettings.json ([#3121](#3121))
* Now that most users will not need to download the debugger themselves (it comes pre-packaged in a platform specific .vsix), this changes back to the Azure CDN instead of https://download.visualstudio.microsoft.com

This also updates `gulp updatePackageDependencies` to support updating packages when the primary URL just has a simple version number.
@gregg-miskelly gregg-miskelly added this to the 1.23.17 milestone Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants