Witik / RiderUserSecrets

MIT License
17 stars 5 forks source link

Plugin opens no-id UserSecrets file if project targets multiple frameworks #24

Open cdonnellytx opened 3 years ago

cdonnellytx commented 3 years ago

It appears that the plugin will create a new file in the UserSecrets base directory (%APPDATA%\Microsoft\UserSecrets\secrets.json on Windows) instead of the expected ID directory underneath.

Steps to reproduce

  1. Use dotnet to create a new project and init user secrets:
dotnet new classlib -n MyProject -f netcoreapp3.1
dotnet new sln -n MySolution
dotnet sln add MyProject
cd MyProject
dotnet user-secrets init
dotnet user-secrets set answer 42
  1. Edit the project by hand and change the TargetFramework to TargetFrameworks with two values:
- <TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
  1. Open the solution in Rider.
  2. Right-click MyProject, Tools -> Open Project User Secrets

Expected: Open file is C:\Users\cdonnelly\AppData\Roaming\Microsoft\UserSecrets\some-uuid\secrets.json Actual: Open file is C:\Users\cdonnelly\AppData\Roaming\Microsoft\UserSecrets\secrets.json

Versions affected

seclerp commented 3 years ago

I could confirm that it is reproducible (Windows, Rider 2021.2, Plugin 1.2.0). And also I could confirm that when initializing secrets from the plugin using "Initialize User Secrets" it opens the correct file, but incorrect with "Open Project User Secrets" in this case

stringit-mcagno commented 2 years ago

I can confirm that is reproducible on macOS too, with the same steps.