Skip to content

dotnet.generateAssets persists C# Dev Kit temporary solution paths in build and publish tasks #9748

Description

@bwateratmsft

Type: Bug

Summary

dotnet.generateAssets can persist C# Dev Kit’s temporary solution path in generated tasks instead of the application’s .csproj. This produces machine-specific configuration and, when the workspace and temporary solution are on different Windows drives, an invalid path.

This affects Container Tools’ Add Docker Files to Workspace command, which delegates .NET asset generation to the C# extension. Tracked downstream in microsoft/vscode-containers#605.

Steps to reproduce

  1. Install the C# and C# Dev Kit extensions.
  2. Create an ASP.NET Core project without a solution file on a drive different from VS Code’s user-data directory:
    dotnet new mvc -o D:\Sandbox\ExampleApp
  3. Open that folder in VS Code and allow Dev Kit to load it in workspace mode.
  4. Run Containers: Add Docker Files to Workspace, selecting ASP.NET Core and Linux.
  5. Inspect the generated .vscode/tasks.json and run the build task.

Container Tools invokes:

vscode.commands.executeCommand(
    'dotnet.generateAssets',
    undefined,
    { skipPrompt: true }
);

Reproduced with:

  • Container Tools 2.5.0
  • C# 2.140.9
  • C# Dev Kit 3.20.207
  • .NET SDK 10.0.400
  • Windows, with the project on D: and VS Code user data on C:

Actual behavior

The generated build, publish, and watch tasks reference a path shaped like:

./${workspaceFolder}/c:/Users/<user>/AppData/Roaming/Code/User/workspaceStorage/<id>/ms-dotnettools.csdevkit/ExampleApp.sln

The build fails with:

MSBUILD : error MSB1009: Project file does not exist.

The original temporary solution does exist on C:. The generated argument is malformed. Building the actual .csproj succeeds.

Even without the cross-drive failure, persisting a solution under VS Code’s workspace storage makes the configuration dependent on the generating user’s environment.

Expected behavior

Persist the selected project’s workspace-relative path in build, publish, and watch tasks, regardless of whether Dev Kit is installed:

${workspaceFolder}/ExampleApp.csproj

Checked-in configuration should work for teammates using the C# extension and .NET SDK without requiring Dev Kit or its generated temporary solution.

Investigation

In src/shared/assets.ts:

  • getBuildProjectPath() prefers any nonempty solutionPath over projectPath.
  • getBuildPath() unconditionally joins ${workspaceFolder} with path.relative(workspace, target). Across Windows drives, the latter returns an absolute path, making the join invalid.

Solution preference was introduced by commit 7fb0321. Dev Kit’s solution-free workspace behavior exposes this by creating solutions outside the workspace.

#9704 already changes watch to use the project path. Build and publish still prefer the solution.

Suggested resolution

Prefer project paths for newly generated persisted tasks, leaving existing user-authored tasks unchanged.

If solution-based build/publish defaults must be retained, please expose a supported dotnet.generateAssets option to request project-based tasks. Currently, selectedIndex selects a project but does not override solution preference, and skipPrompt only controls the Dev Kit recommendation dialog.

Such an option would let Container Tools request portable configuration without duplicating C# asset generation or post-processing tasks.json and launch.json.

Extension version: 2.140.9
VS Code version: Code 1.137.0 (645f29cc3176500b4b5762ba887cf2a7f0ffdf2c, 2026-09-08T13:43:59-07:00)
OS version: Windows_NT x64 10.0.26200
Modes:

Logs

C# log

Details
2026-09-10 12:01:59.170 [info] Locating .NET runtime version 10.0.5
2026-09-10 12:01:59.455 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-09-10 12:01:59.455 [info] Activating C# + C# Dev Kit...
2026-09-10 12:02:00.047 [info] info: Program[0]
2026-09-10 12:02:00.047 [info]       Server started with process ID 9236
2026-09-10 12:02:00.875 [info] [Program] Language server initialized
2026-09-10 12:02:00.877 [info] [Program] Monitoring client process 9804 for exit
2026-09-10 12:02:01.531 [info] [initialized] [Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.FileBasedProgramsEntryPointDiscovery] Finished discovery in 'd:\Sandbox\ContainersIssue605-55ffe9f3' in 9 milliseconds
2026-09-10 12:02:04.881 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project D:\Sandbox\ContainersIssue605-55ffe9f3\ContainersIssue605.csproj loaded by C# Dev Kit

C# LSP Trace Logs log

Details

Environment Information

VSCode version: 1.137.0
C# Extension: 2.140.9
Using OmniSharp: false

Dotnet Information .NET SDK: Version: 10.0.400 Commit: 14fbf8d527 Workload version: 10.0.400-manifests.b0ae88bd MSBuild version: 18.9.6+14fbf8d52

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.400\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.12
Architecture: x64
Commit: 95017c711e

.NET SDKs installed:
8.0.425 [C:\Program Files\dotnet\sdk]
9.0.318 [C:\Program Files\dotnet\sdk]
10.0.400 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
DOTNET_CLI_UI_LANGUAGE [en-US]

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Visual Studio Code Extensions
Extension Author Version Folder Name
azure-dev ms-azuretools 0.10.0 ms-azuretools.azure-dev-0.10.0
csdevkit ms-dotnettools 3.20.207 ms-dotnettools.csdevkit-3.20.207-win32-x64
csharp ms-dotnettools 2.140.9 ms-dotnettools.csharp-2.140.9-win32-x64
debugpy ms-python 2026.6.0 ms-python.debugpy-2026.6.0-win32-x64
esbuild-problem-matchers connor4312 0.0.3 connor4312.esbuild-problem-matchers-0.0.3
memento-explorer bwater 0.1.7 bwater.memento-explorer-0.1.7
native-preview TypeScriptTeam 0.20260708.2 typescriptteam.native-preview-0.20260708.2-win32-x64
python ms-python 2026.4.0 ms-python.python-2026.4.0-win32-x64
remote-containers ms-vscode-remote 0.469.0 ms-vscode-remote.remote-containers-0.469.0
remote-explorer ms-vscode 0.5.0 ms-vscode.remote-explorer-0.5.0
remote-ssh ms-vscode-remote 0.128.0 ms-vscode-remote.remote-ssh-0.128.0
remote-ssh-edit ms-vscode-remote 0.87.0 ms-vscode-remote.remote-ssh-edit-0.87.0
vscode-azure-github-copilot ms-azuretools 1.0.231 ms-azuretools.vscode-azure-github-copilot-1.0.231-win32-x64
vscode-azure-mcp-server ms-azuretools 2.0.46 ms-azuretools.vscode-azure-mcp-server-2.0.46-win32-x64
vscode-azureappservice ms-azuretools 0.27.0 ms-azuretools.vscode-azureappservice-0.27.0
vscode-azurefunctions ms-azuretools 1.22.1 ms-azuretools.vscode-azurefunctions-1.22.1
vscode-azureresourcegroups ms-azuretools 0.12.7 ms-azuretools.vscode-azureresourcegroups-0.12.7
vscode-containers ms-azuretools 2.5.0 ms-azuretools.vscode-containers-2.5.0
vscode-dotnet-runtime ms-dotnettools 3.1.0 ms-dotnettools.vscode-dotnet-runtime-3.1.0
vscode-eslint dbaeumer 3.0.34 dbaeumer.vscode-eslint-3.0.34
vscode-pull-request-github GitHub 0.166.0 github.vscode-pull-request-github-0.166.0
vscode-pylance ms-python 2026.3.1 ms-python.vscode-pylance-2026.3.1
vscode-remote-extensionpack ms-vscode-remote 0.26.0 ms-vscode-remote.vscode-remote-extensionpack-0.26.0
vscode-yaml redhat 1.24.0 redhat.vscode-yaml-1.24.0
C# Settings
Setting Value
preferCSharpExtension false
compilerDiagnosticScope openFiles
analyzerDiagnosticScope openFiles
enableXamlTools true
useServerGC true
System Info
Item Value
CPUs Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz (20 x 3696)
GPU Status 2d_canvas: enabled
GPU0: VENDOR= 0x8086, DEVICE=0x9bc5 [Intel(R) UHD Graphics 630], DRIVER_VENDOR=Intel, DRIVER_VERSION=30.0.101.1273 ACTIVE
GPU1: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.9278
Machine model name:
Machine model version:
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 126.84GB (102.06GB free)
Process Argv --log ms-azuretools.azureextensionui=trace --log ms-azuretools.vscode-containers=debug --log ms-azuretools.vscode-azure=debug --crash-reporter-id 346e43a8-9268-4087-a447-da84e0fdc384
Screen Reader yes
VM 0%

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions