Open InsanityCode opened 6 months ago
I am aware that there is a similar issue at https://github.com/microsoft/vscode-dotnettools/issues/114. This issue is already closed, but the problem described above still exists.
Using the steps described above I created a little Test Repository that demonstrates the problem.
It seems I forgot to mention that MSB4019 also occurs when attempting to start the program using F5.
./Demo/DemoProject/Program.cs
in the editorSelect debugger
, select C#
Select Launch Configuration
, select C#: DemoProject
In the build output we can see that the executed command is
dotnet build X:/full/path/to/Demo/DemoProject/DemoProject.csproj `
/property:GenerateFullPaths=true `
/consoleloggerparameters:NoSummary
This command does not provide any information about the solution.
Manually specifying SolutionDir
works just fine:
dotnet build ./Demo/DemoProject/DemoProject.csproj --property:SolutionDir="$(Get-Location)/Demo/"
As for actually running the project...
The dotnet run
Description states that
dotnet run
doesn't respect arguments like/property:property=value
, which are respected bydotnet build
.
allthough on the same page in Options it says
- --property:<NAME>=<VALUE> Sets one or more MSBuild properties. [...]
Either way, for both
dotnet run --project ./Demo/DemoProject/DemoProject.csproj --property:SolutionDir="$(Get-Location)/Demo/"
and
dotnet build ./Demo/DemoProject/DemoProject.csproj --property:SolutionDir="$(Get-Location)/Demo/"
dotnet run --project ./Demo/DemoProject/DemoProject.csproj --no-build
dotnet run
fails, printing that ./Demo/DemoProject/DemoProject.csproj is not a valid project file
without any information why.
Related issue: https://github.com/dotnet/sdk/issues/22342
Describe the Issue
Running a single project from the solution explorer does not set the
SolutionDir
property for the built project.The term 'Solution Explorer' implies that a solution file is present.
So when building or running a project from the solution explorer,
SolutionDir
should be set for the built project.Steps To Reproduce
Open Visual Studio Code in an empty folder
Create a solution
Create a project
Add the project to the solution
Create
./Demo/DemoImport.props
with the following contentImport
./Demo/DemoImport.props
into the project by adding the following lineRight click
DemoProject
in the Solution Explorer and selectDebug
->Start New Instance
The build then fails with MSB4019 stating that
X:/DemoImport.props
could not be found.This is because
$(SolutionDir)
evaluates to an empty string which leads to the remaining path/DemoImport.props
being interpreted as an absolute path.The same happens when you right click the solution and select
Clean
and then right click the project and selectBuild
.This does not occur when right clicking the project and selecting
Rebuild
.Selecting
Build
orRebuild
on the solution works as well.Expected Behavior
DemoProject builds and then runs.
During the build it prints
Hello, Demo!
.When running it prints
Hello, World!
.Environment Information