microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
207 stars 7 forks source link

[BUG] can not build or debug a csharp project in a sln if sln have some problem #1187

Open heartacker opened 2 weeks ago

heartacker commented 2 weeks ago

Describe the Issue

but csproj is ok. and we could start debug that proj individually by vs 2022 or dotnet cli command

Steps To Reproduce

 *  正在执行任务: dotnet: build D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo.Desktop\Ursa.Demo.Desktop.csproj 

dotnet build D:\heart\Git\Ursa.Avalonia\VariableBox.sln /target:Ursa_Demo_Desktop /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Debug /p:Platform="Any CPU" 
  Determining projects to restore...
  跳过项目“D:\heart\Git\Ursa.Avalonia\src\Ursa.PrismExtension\Ursa.PrismExtension.csproj”,因为未找到该项目。
  跳过项目“D:\heart\Git\Ursa.Avalonia\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj”,因为未找到该项目。
  跳过项目“D:\heart\Git\Ursa.Avalonia\src\Ursa.PrismExtension\Ursa.PrismExtension.csproj”,因为未找到该项目。
  跳过项目“D:\heart\Git\Ursa.Avalonia\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj”,因为未找到该项目。
  所有项目均是最新的,无法还原。
D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo\Ursa.Demo.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。
D:\heart\Git\Ursa.Avalonia\src\VariableBox.Themes.Semi\VariableBox.Themes.Semi.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。
D:\heart\Git\Ursa.Avalonia\demo\Ursa.PrismDialogDemo\Ursa.PrismDialogDemo.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。
D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo.Desktop\Ursa.Demo.Desktop.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。
D:\heart\Git\Ursa.Avalonia\src\VariableBox\VariableBox.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。
D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo.Browser\Ursa.Demo.Browser.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。
D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo.Android\Ursa.Demo.Android.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。
D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo.iOS\Ursa.Demo.iOS.csproj : error MSB4057: 该项目中不存在目标“Ursa_Demo_Desktop”。

 *  终端进程已终止,退出代码: 1。 
 *  终端将被任务重用,按任意键关闭。

and dotnet cli

 dotnet build
  Determining projects to restore...
  所有项目均是最新的,无法还原。
  VariableBox -> D:\heart\Git\Ursa.Avalonia\src\VariableBox\bin\Debug\netstandard2.0\VariableBox.dll
  VariableBox.Themes.Semi -> D:\heart\Git\Ursa.Avalonia\src\VariableBox.Themes.Semi\bin\Debug\netstandard2.0\VariableBox.Themes.Semi.dll
  VariableBox -> D:\heart\Git\Ursa.Avalonia\src\VariableBox\bin\Debug\net8\VariableBox.dll
  Ursa.Demo -> D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo\bin\Debug\net8.0\Ursa.Demo.dll
  Ursa.Demo.Desktop -> D:\heart\Git\Ursa.Avalonia\demo\Ursa.Demo.Desktop\bin\Debug\net8.0\Ursa.Demo.Desktop.dll

``

Expected Behavior

No response

Environment Information

名称: C# Dev Kit ID: ms-dotnettools.csdevkit 说明: Official C# extension from Microsoft 版本: 1.7.22 发布者: Microsoft VS Marketplace 链接: https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit

pikami commented 2 weeks ago

I just had the same issue. You are using the version 1.7.22 which is the "pre-release" version. Swich to the latest release 1.6.8 from the extension market place, restart vscode and it will fix this issue for you.

ZoBoRf commented 2 weeks ago

Same problem here for "C# Dev Kit" v.1.7.25 (in previous version 1.6 there was no problem.):

vscode ➜ /workspace/LVP/aspnet-core (develop) $ pwd
/workspace/LVP/aspnet-core
vscode ➜ /workspace/LVP/aspnet-core (develop) $ ls -l
total 28
drwxr-xr-x 2 vscode vscode 4096 Dec 15 21:49 build
drwxr-xr-x 3 vscode vscode 4096 Dec 10  2023 docker
-rw-r--r-- 1 vscode vscode 5510 Dec 10  2023 LVP.sln
drwxr-xr-x 2 vscode vscode 4096 Mar 20 12:14 obj
drwxr-xr-x 8 vscode vscode 4096 Jan 10 14:18 src
drwxr-xr-x 5 vscode vscode 4096 Dec 10  2023 test
vscode ➜ /workspace/LVP/aspnet-core (develop) $ ls -l src
total 24
drwxr-xr-x 41 vscode vscode 4096 Jun 13 06:40 LVP.Application
drwxr-xr-x 27 vscode vscode 4096 Apr 29 10:10 LVP.Core
drwxr-xr-x  6 vscode vscode 4096 May  3 12:48 LVP.EntityFrameworkCore
drwxr-xr-x  6 vscode vscode 4096 Dec 10  2023 LVP.Migrator
drwxr-xr-x 10 vscode vscode 4096 Apr 29 10:10 LVP.Web.Core
drwxr-xr-x 12 vscode vscode 4096 Jun  7 12:10 LVP.Web.Host
vscode ➜ /workspace/LVP/aspnet-core (develop) $ dotnet build /workspace/LVP/aspnet-core/LVP.sln /target:LVP_Web_Host /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Debug /p:Platform="Any CPU"
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
/workspace/LVP/aspnet-core/test/LVP.Tester/LVP.Tester.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.
/workspace/LVP/aspnet-core/src/LVP.Application/LVP.Application.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.
/workspace/LVP/aspnet-core/src/LVP.Web.Core/LVP.Web.Core.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.
/workspace/LVP/aspnet-core/test/LVP.Tests/LVP.Tests.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.
/workspace/LVP/aspnet-core/src/LVP.EntityFrameworkCore/LVP.EntityFrameworkCore.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.
/workspace/LVP/aspnet-core/src/LVP.Migrator/LVP.Migrator.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.
/workspace/LVP/aspnet-core/src/LVP.Web.Host/LVP.Web.Host.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.
/workspace/LVP/aspnet-core/src/LVP.Core/LVP.Core.csproj : error MSB4057: The target "LVP_Web_Host" does not exist in the project.

Adding src\\ to /target: parameter:

vscode ➜ /workspace/LVP/aspnet-core (develop) $ dotnet build /workspace/LVP/aspnet-core/LVP.sln /target:src\\LVP_Web_Host /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Debug /p:Platform="Any CPU"
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  LVP.Core -> /workspace/LVP/aspnet-core/src/LVP.Core/bin/Debug/net8.0/LVP.Core.dll
  LVP.Application -> /workspace/LVP/aspnet-core/src/LVP.Application/bin/Debug/net8.0/LVP.Application.dll
  LVP.EntityFrameworkCore -> /workspace/LVP/aspnet-core/src/LVP.EntityFrameworkCore/bin/Debug/net8.0/LVP.EntityFrameworkCore.dll
  LVP.Web.Core -> /workspace/LVP/aspnet-core/src/LVP.Web.Core/bin/Debug/net8.0/LVP.Web.Core.dll
  LVP.Web.Host -> /workspace/LVP/aspnet-core/src/LVP.Web.Host/bin/Debug/net8.0/LVP.Web.Host.dll
vscode ➜ /workspace/LVP/aspnet-core (develop) $ 

The build generates "/target:LVP_Web_Host" but it should be "/target:src\LVP_Web_Host". "Rebuild" is ok:

 *  Executing task: dotnet: rebuild /workspace/LVP/aspnet-core/src/LVP.Web.Host/LVP.Web.Host.csproj 

dotnet build /workspace/LVP/aspnet-core/LVP.sln /target:src\LVP_Web_Host:rebuild /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Debug /p:Platform="Any CPU" 
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
/workspace/LVP/aspnet-core/src/LVP.Core/Identity/SecurityStampValidator.cs(18,13): warning CS0618: 'ISystemClock' is obsolete: 'Use TimeProvider instead.' [/workspace/LVP/aspnet-core/src/LVP.Core/LVP.Core.csproj]
  LVP.Core -> /workspace/LVP/aspnet-core/src/LVP.Core/bin/Debug/net8.0/LVP.Core.dll
  LVP.Application -> /workspace/LVP/aspnet-core/src/LVP.Application/bin/Debug/net8.0/LVP.Application.dll
  LVP.EntityFrameworkCore -> /workspace/LVP/aspnet-core/src/LVP.EntityFrameworkCore/bin/Debug/net8.0/LVP.EntityFrameworkCore.dll
...
  LVP.Web.Core -> /workspace/LVP/aspnet-core/src/LVP.Web.Core/bin/Debug/net8.0/LVP.Web.Core.dll
  LVP.Web.Host -> /workspace/LVP/aspnet-core/src/LVP.Web.Host/bin/Debug/net8.0/LVP.Web.Host.dll
 *  Terminal will be reused by tasks, press any key to close it. 
ZoBoRf commented 1 week ago

It's closed in https://github.com/microsoft/vscode-dotnettools/issues/1200