sdk icon indicating copy to clipboard operation
sdk copied to clipboard

`dotnet run` needs to pass NuGet cache probing path to dotnet.exe

Open TheRealPiotrP opened this issue 10 years ago • 17 comments

@schellap, this is tracking the work to provide dotnet.exe with an additional probing path in the dotnet run scenario. Can you provide a link for the relevant dotnet.exe issue so we can take a dependency on it?

/cc @gkhanna79

TheRealPiotrP avatar Feb 26 '16 21:02 TheRealPiotrP

@brthor, once @shellap is ready for this change please prioritize the work.

TheRealPiotrP avatar Mar 10 '16 03:03 TheRealPiotrP

@schellap @gkhanna79 Can you please provide some more context on this feature?

brthor avatar Mar 11 '16 02:03 brthor

The additional probing path is necessary to specify nuget packages cache and there will no more reference or fallback to it unless it is explicitly passed in to the app.

NuGet packages cache is an external artifact that is outside the FX and the app and could potentially be corrupt or be mucked with -- so the host will no longer know about this location unless specified. This means any code that relies on the nuget cache being the last resort will break. For example: xunit.

schellap avatar Mar 11 '16 03:03 schellap

Currently the host detects it to be ~/.nuget and %USERPROFILE%\.nuget. This will no longer work.

schellap avatar Mar 11 '16 03:03 schellap

I don't quite understand this bug. So if I run a dll using dotnet, all depended outside of the shared framework need to be copied to hr output folder?

davidfowl avatar Mar 11 '16 04:03 davidfowl

@davidfowl, no, the host gives a choice to where you want to look for the --packages. CLI or app can still specify path (potentially pass along the --packages or specify --additionalprobingpath to nuget cache) to the host, but that is up to the app.

The intent here being, for a production app (non dev scenario) NuGet cache shouldn't turn into a GAC where it is left in a bad state by users on a machine and we might hit issues because of that.

schellap avatar Mar 11 '16 04:03 schellap

when was this decision made?

davidfowl avatar Mar 11 '16 04:03 davidfowl

For non dev scenarios, the app closure is either app local or in shared framework (excluding servicing or antares cache).

The dev scenario would not have the above true and thus, may require a fallback. This argument is to support that fallback. @davidfowl we talked about this multiple times in our marathon syncs and is called out in OneNote too.

gkhanna79 avatar Mar 11 '16 04:03 gkhanna79

I can't recall anything about explicitly passing he packages folder. So it means that dotnet run will work but dotnet foo.dll won't work? So all parties need to understand when to pass in the packages folder?

davidfowl avatar Mar 11 '16 05:03 davidfowl

When does a production app scenario not have a complete closure between shared fx and app?

gkhanna79 avatar Mar 11 '16 06:03 gkhanna79

Who said anything about production? I'm on my dev box and I'm not using dotnet run. Now I have to pass in the packages folder?

davidfowl avatar Mar 11 '16 06:03 davidfowl

No you dont. Why would you need to?

gkhanna79 avatar Mar 11 '16 06:03 gkhanna79

Also, please have a look at the activation OneNote. If that does not clarify, feel free to chat tomorrow.

gkhanna79 avatar Mar 11 '16 06:03 gkhanna79

what gets copied to the output folder on build?

davidfowl avatar Mar 11 '16 06:03 davidfowl

If the output of build/compile does not result in an activatable portable or standalone app (equivalent to what happens in publish), then you are still in "dev" mode and would need to use "dotnet run" to execute the app.

"dotnet run" implementation will take care of passing this flag to indicate to the host the additional cache that needs to be probed. The user of "dotnet run" is abstracted away from the detail since for a production scenario (full published portable or standalone app, whether or not on your dev box) will not need such a cache.

"dotnet " expects it is a published portable or standalone app.

gkhanna79 avatar Mar 11 '16 15:03 gkhanna79

Are there more situations where the information for the packages cache location is needed?

For example given the directory structure:

bin\
    foo.dll
    foo.deps.json

Invoking dotnet bin/foo.dll would load the foo.deps.json and the cache information was not passed in.

Is this intended to be a failure scenario or does the host retain some fallback logic?

brthor avatar Mar 11 '16 20:03 brthor

When an application is published, all of its dependency closure falls in one of the following two categories:

  1. For a portable app, the closure is split between SharedFramework and AppLocal locations
  2. For standalone app, the closure is all within the AppLocal location

As a result, there should never be a need to reference a fallback location. Such a need only arises when the application is being developed and, thus, has not been published. Scenarios like "dotnet run" or doing "dotnet " falls into this category.

For "dotnet run" like scenarios, it is very clear to the muxer that it needs to invoke the CLI, which will, in turn, pass the additional probing path.

For scenarios like "dotnet ", unless there is a hint in the app.runtimeconfig.json or app.deps.json, the muxer will will think it is a published app and will attempt to execute it. Since the app will not be in one of the two categories above (published as portable or standalone), one of the following should be done to ensure the fallback cache location is identified:

  1. We make a statement that for non-published applications to run, one always must do "dotnet run " to execute it, OR
  2. There needs to be a hint in app.runtimeconfig.json or app.deps.json, for the non-published app case, that the muxer reads to determine that the application is not published and map the invocation to "dotnet run " so that CLI does the right thing and pass the additional probing path.

Thus, for your scenario above @brthor, we could just say that you need to invoke the unpublished app as "dotnet run bin/foo.dll" and the right thing will happen. However, since folks are already using "dotnet " even for unpublished app cases, I think it will be helpful for a hint to be provided to the muxer so that it maps the invocation in your example to "dotnet run bin/foo.dll.

Ofcourse, once the app is published (portable or standalone), there will be no such hint at all.

@anurse @schellap Thoughts?

gkhanna79 avatar Mar 13 '16 15:03 gkhanna79