Project-system: Current working directory for Net Core Console application is project directory

Created on 19 May 2017  路  10Comments  路  Source: dotnet/project-system

@davkean
Regression? of .NET Core console app default working directory is the source directory, not the bin directory

Using Visual Studio Enterprise 2017, version 15.2 (26430.6), .NETCoreApp 1.1

Inserted
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
as first line in Main as workaround.

Bug Feature-Debugging

Most helpful comment

I'm in agreement here - I don't think it's important to have to consistency between web and non-web, it's better to be consistent between what happens if you run with and without debugger, both inside and outside of VS.

All 10 comments

@BillHiebert Is there a reason we made working directory default to the project directory for non-web projects?

The rationale for the change was that consistency between VS and CLI for Net core projects was more important than consistency between desktop projects and netcore projects. See discussion - https://github.com/dotnet/cli/issues/4473#issuecomment-256502969

@srivatsn, what is the definition of project directory? And what is a desktop project?

@srivatsn, @davkean. I think the whole debacle is caused by a misunderstanding of this post https://github.com/dotnet/cli/issues/4473#issuecomment-256531057

"If RunWorkingDirectory comes back blank, VS will need to default the working directory during F5.", and this defaulting should of course be existing behavior of systems in production! Not the behavior of a beta product where there have been reported issued about this behavior.

I'm in agreement here - I don't think it's important to have to consistency between web and non-web, it's better to be consistent between what happens if you run with and without debugger, both inside and outside of VS.

I came here to wonder about this very behavior, and agree.

Not sure this is related: I added a postbuild event as a target to the project file to execute a command in a particular working directory. In this case the macro $(SolutionDir) is not set to the solution as I expected but set to the directory of the project which in turn is in a directory underneath the one that contains the solution file.

<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Exec Command="dotnet &quot;$(TargetPath)&quot; /create-shared-assembly-info-file" WorkingDirectory="$(SolutionDir)"></Exec> </Target>

@BillHiebert didn't we have another thread about this recently? Do you know where to change this?

@Pilchie - I just pushed this PR https://github.com/dotnet/project-system/pull/3073 which contains the fix for this issue.

Closing as fixed by #3073.

Was this page helpful?
0 / 5 - 0 ratings