Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Starting console application project resource does not honor workingDirectory option of the launch profile #304

Closed
anadale opened this issue Nov 21, 2024 · 1 comment · Fixed by #315
Assignees
Labels
bug Something isn't working

Comments

@anadale
Copy link

anadale commented Nov 21, 2024

Describe the bug
Starting an AppHost that has a reference to the console application ends up with the console application's current working directory be in the bin/Debug/netX folder even if the option workingDirectory of the launch profile points to the folder containing the project file. As a result, corresponding appsettings.json file is not found and proper configuration is not loaded.

This is not the case for the Web applications, their ContentRoot is properly set to the folder, containing the project file. Starting the AppHost from the command line works as expected, and the CWD of the console application is set to the one, specified in the launch profile. Starting the ConsoleApplication from Rider as a configured .Net Launch Settings Profile entry also honor the workingDirectory option.

To Reproduce
Steps to reproduce the behavior:

  1. Create the solution, containing AppHost and two projects: WebApplication and ConsoleApplication.
  2. Add Console.WriteLine(Environment.CurrentDirectory); to the top of both Program.cs files.
  3. For both projects create the Properties/launchSettings.json file with the following content:
{
  "profiles": {
    "Project": {
      "commandName": "Project",
      "workingDirectory": "$(MSBuildProjectDirectory)",
      "environmentVariables": {
        "DOTNET_ENVIRONMENT": "Development"
      }
    }
  }
}
  1. Add both projects as a dependencies to the AppHost project; add that projects as a resources to IDistributedApplicationBuilder.
  2. Run the AppHost from the "Run/Debug Configurations" widget.
  3. Web application prints the path of the WebApplication.csproj file (.../WebApplication) while Console application prints the path of the built executable (.../ConsoleApplication/bin/Debug/net9) ignoring the workingDirectory option of the launch profile.

Expected behavior
Web application should print to the console the path to the folder, containing WebApplication.csproj file, for example .../WebApplication. Console application should print to the console the path to the folder, containing ConsoleApplication.csproj file, for example .../ConsoleApplication.

System information:

  • OS: MacOS
  • .NET version: 9.0.0
  • JetBrains Rider version: 2024.3
  • Aspire plugin version: 1.6.0
  • Aspire workload version: n/a for Aspire 9
@rafaelldi
Copy link
Collaborator

Thank you for the report. It should be fixed with #315. Please also make sure that you have the same profile name for the host and dependant projects or use the launchProfileName parameter (more details here).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants