Share via

VSIX Extension Which Provides Setting Overrides During Debugging of Target Application

2026-04-21T14:11:44.31+00:00

I am attempting to create a VSIX extension which allow app settings to be overridden while the target application is being debugged (similar to User Secrets), however nothing I have tried has worked and feel that I must be missing something basic. My goal is for the extension to be able to provide overrides for configuration values without having anything permanent written to the file system. However, every example I have found either doesn't work or doesn't meet my goals. At a minimum I would like this to work for ASP.NET Core applications (.NET6+) and (if possible) console applications, but at the moment I am focusing only on the ASP.NET projects.

I was able to create the extension and have it run when the target application is executed, but it never gets the new values. I tried implementing the suggestions provided under How to write a Visual Studio extension that injects environment variables into a .NET 4.8 application on debug launch but neither suggestion worked. For Option A, implement a launch settings provider, I was unable to find how to bring in IVsDebugLaunchSettingsProvider to the VSIX project. This interface was not available in any assemblies I added. There as a similar interface I saw a recommendation from, ILaunchSettingsProvider, but again I was not able to find any way to inherit this interface.

For Option B, I also couldn't find out how to just add environment variables to the config. Various suggestions I saw suggested retrieving Environment or EnvironmentVariables from the properties, but neither of these existed in the target application while it was debugging.

I was only able to find two ways that worked. First, I was able to find is to write the values to the launchSettings.json file, however this has two issues. For console applications, this file doesn't necessarily exist. Even restricting to ASP.NET applications, this file is still under source control and the changes the extension makes should only be available during the debugging session; there should be no risk of the changes being committed to the repository.

The second was by using Environment.SetEnvironmentVariable("MaintenanceConfiguration__MaintenanceWindowCheckEnabled", "False", EnvironmentVariableTarget.User); but that adds it permanently and then would have to worry about cleaning that up when the debugging is completed. I did try using EnvironmentVariableTarget.Process at first, but that didn't work I am assuming because the extension is running in its own process.

The other issue I see with using the environment variables in this way is that some of our solutions have multiple projects that are ran together. They may potentially have the same settings structure, e.g. MaintenanceConfiguration__MaintenanceWindowCheckEnabled, however one may need this to be true and the other false and by having a single environment variable, it will force them to be the same.

What I am looking for is how can I implement a extension that does the following:

  1. When target application is started, the extension can override one or more app setting values (or add if necessary)
  2. The updated values are immediately available using IConfiguration in the target application
  3. No changes to the file system that could potentially get checked into source control

Is what I am attempting to do even possible? Any help or guidance would be greatly appreciated as I have been working on this for two days without any real progress. TIA.

Developer technologies | Visual Studio | Extensions
0 comments No comments

1 answer

Sort by: Most helpful
  1. Adiba Khan 2,345 Reputation points Microsoft External Staff
    2026-04-22T10:59:46.5766667+00:00

    Thank you for detailed explanation. This is well thought out scenario and you are not missing anything obvious. What you are trying to achieve (runtime-only configuration overrides during debugging, without touching disk or persisting state) is not directly supported by current Visual Studio extensibility model, which is why the approaches you tried are hitting limitations.

    That said, here's the most accurate and recommended approach, along with clarification on why the previous attempts didn't work.

    Key Limitation

    A VSIX extension runs in a separate process(devenv.exe) and does not have direct control over the configuration pipeline of the debugged process (your ASP.NET Core app).

    This means:

    • EnvironmentVariableTarget.Process -> applies to VS process, not target app.
    • User/Machine-> persists (not desired)
    • launchSettings.json-> file-based ( not desired).

    Recommended Approach (Supported and clean)

    Use Debug Launch Customizable via DebugLaunchProvider

    Instead of trying modify config after launch, you should inject environment variables at debug launch time using:

    IDebugProfileLaunchTargetsProvider (modern approach)

    This is the correct extensibility point for .NET Core / ASP.NET Core projects.

    What this gives you:

    • Runtime-only overrides
    • No file system changes
    • Scoped to debug session
    • Works with ASP.NET Core config system (IConfiguration)

    Implementation Outline

    1. Create a VSIX extension
    2. Export a custom launch provider:
         [Export(typeof(IDebugProfileLaunchTargetProvider))]
         [AppliesTo(ProjectCapability.DotNetCore)]
         public class CustomLaunchProvider : IDebugProfileLaunchTargetsProvider
         {
         	public Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync(
         		DebugLaunchOptions launchOptions,
         		ILaunchProfile profile)
         	{
         		var settings = new DebugLaunchSettings(launchOptions)
         		{
         			LaunchOperations = DebugLaunchOperation.CreateProcess,
         			Executable = profile.ExecutablePath,
         			Arguments = profile.CommandLineArgs,
         			CurrentDirectory = profile.WorkingDirectory
         		};
         
         		//Inject environment variable here
         		settings.Environment["MaintenanceConfiguration__MaintenanceWindowCheckEnabled'] = "false";
         		
         		return Task.FromResult<IReadOnlyList<IDebugLauncgSettings>>(
         			new[] {settings});
         	}
         }
         
         
      

    Important notes

    • Use __(double underscore) for nested config keys in ASP.NET Core.
    • These values will be picked up automatically via: IConfiguration["MaintenanceConfiguration__MaintenanceWindowCheckEnabled'] = "false";
    • This only applies during debugging, exactly matching your requirement

    Alternative (if you need more control)

    if you need even more flexibility (e.g., per-project overrides in multi-project solutions):

    • Implement a custom configuration provider in your app.
    • Read values from a temporary in-memory source (e.g., named pipe, local service, etc.)

    But this require app-level changes, whereas the above VSIX approach does not.

    Please try the steps shared above and let me know if this resolves the issue.

    If it works, you may mark this reply as the Accepted Answer — this helps other customers with similar questions find the solution faster.

    2 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.