Skip to content

Current working directory for Net Core Console application is project directory #2239

Closed

Description

@pi3k14

@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.

Activity

  1. davkean commented on May 22, 2017

    @davkean
    Member

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

  2. srivatsn commented on May 23, 2017

    @srivatsn
    Contributor

    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

  3. pi3k14 commented on May 24, 2017

    @pi3k14
    Author

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

  4. pi3k14 commented on May 24, 2017

    @pi3k14
    Author

    @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.

  5. davkean commented on May 24, 2017

    @davkean
    Member

    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.

  6. added this to the 15.6 milestone on May 26, 2017
  7. niwrA commented on May 31, 2017

    @niwrA

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

  8. ManfredLange commented on Jul 31, 2017

    @ManfredLange

    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>

  9. removed their assignment
    on Sep 27, 2017
  10. modified the milestones: 15.5, 15.6 on Oct 17, 2017
  11. Pilchie commented on Dec 20, 2017

    @Pilchie
    Member

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

  12. added
    Feature-Debugging
    on Dec 20, 2017
  13. BillHiebert commented on Dec 21, 2017

    @BillHiebert
    Contributor

    @Pilchie - I just pushed this PR #3073 which contains the fix for this issue.

  14. Pilchie commented on Jan 10, 2018

    @Pilchie
    Member

    Closing as fixed by #3073.

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

Metadata

Metadata

Assignees

Labels

Feature-Debugging

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions