Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[BUG] dotnet restore does not use CLI from dotnet.dotnetPath #63

Closed
Tracked by #492
sandyarmstrong opened this issue Jun 7, 2023 · 12 comments
Closed
Tracked by #492
Labels
area-restore bug Something isn't working
Milestone

Comments

@sandyarmstrong
Copy link
Member

sandyarmstrong commented Jun 7, 2023

Describe the Issue

Errors like the following occur during restore:

/usr/local/share/dotnet/sdk/7.0.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: macos

Note that it is using the global dotnet SDK location instead of the one specified in dotnet.dotnetPath.

It seems like the implementation of dotnetCommand does not take this setting into account.

Steps To Reproduce

  1. Have a solution with projects that depend on .NET workloads (for example, macos or maui).
  2. Use a locally-provisioned .NET SDK for builds, where those workloads are properly installed.
  3. Specify the path for that .NET SDK in dotnet.dotnetPath in workspace settings.
  4. Open solution in VS Code.

Expected Behavior

NuGet restore should work without issue.

Environment Information

  • C# Dev Kit extension v0.1.83
  • C# extension v2.0.206
@kartheekp-ms
Copy link
Member

@arkalyanms - I have removed area-restore label to this issue because @marcpopMSFT added area-sdk label. Given that this issue appears to be related to .NET SDK, I have removed my assignment for this issue.

@kartheekp-ms kartheekp-ms removed their assignment Aug 21, 2023
@smitpatel smitpatel removed the triaged The issue has been triaged label Aug 21, 2023
@marcpopMSFT
Copy link

That setting is not for controlling the SDK or the customer's dotnet environment but rather just for the local install of the runtime used in the devkit extension per my understanding:
Specified the path to a dotnet installation to use instead of the default system one. This only influences the dotnet installation to use for hosting the language server itself. Example: "/home/username/mycustomdotnetdirectory".

So the behavior you're seeing seems pretty expected to me. Not sure why you wanted to control this through the IDE settings as we've never had the ability to control dotnet outside of the path/global.json (and global.json doesn't control where the SDK is, only environment variables).

CC @lifengl who probably knows where that setting is actually used.

@sandyarmstrong
Copy link
Member Author

Not sure why you wanted to control this through the IDE settings as we've never had the ability to control dotnet outside of the path/global.json (and global.json doesn't control where the SDK is, only environment variables).

But we should have this ability. See also dotnet/sdk#8254.

@nagilson
Copy link
Member

@marcpopMSFT @baronfel This is part of the 'GA' milestone so we should resolve it before then, I don't know if we have any actionable items we can do from this by GA, and whether this should be a fix in the SDK, VS Code Runtime Ext, or CDK/C#. If you have more context on this issue, may you please advise? Thank you ;)

@nagilson
Copy link
Member

We talked about it more; it looks like CDK has a dotnetCommand which you are referring to and that is not part of the SDK or Runtime Extension, you would have to change that code to make it use the dotnet on the setting you mentioned as dotnet.dotnetPath. As for the change in the SDK, that is not accomplishable by GA and is a separate issue that should be tracked in the SDK itself like you mentioned. Any follow up can go there, it's a great point but I'm not sure when it will be done.

@sandyarmstrong
Copy link
Member Author

@nagilson so where is the best place to file C# Dev Kit bugs?

@nagilson nagilson reopened this Sep 12, 2023
@nagilson
Copy link
Member

Here is good -- for the dotnetCommand, @kartheekp-ms may you please check and see if this CDK restore command could adhere to using the dotnet.dotnetPath?

@nagilson
Copy link
Member

If that is not even a viable option, please let us know @marcpopMSFT

@marcpopMSFT
Copy link

To clarify, the original ask was for a settings that would control the location of the SDK used by C#DK. The existing setting is specific to the version of the runtime being used by the extension and does not apply to the SDK calls (builds, restores, tests, etc). I don't think we want individual teams in DK implementing ways of finding and honoring a flag.

We don't have a way of specifying an alternative way of doing this outside of the PATH environment variable and per the linked issue, there is disagreement on what an alternative solution would look like. I think this is a reasonable ask but probably something that should be fixed by global.json rather than DK.

@nagilson
Copy link
Member

Ok, I agree this is more of an SDK issue. Sorry. @kartheekp-ms my earlier comment was not a good idea, Like, you could change the behavior of just the restore command but I think then it would be disparate from all of the other commands. So, you would likely have to change the behavior for all of the commands, which is really just something that should be done in the SDK.

This is the correct place for CDK feedback but this change should really be tracked in the SDK.

@sandyarmstrong
Copy link
Member Author

The existing setting is specific to the version of the runtime being used by the extension and does not apply to the SDK calls (builds, restores, tests, etc).

Gotcha. Hopefully this is well-documented in the settings to avoid future confusion.

@nagilson
Copy link
Member

I will close this since the SDK issue should be tracking this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-restore bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants