How to set up standalone development with .net Core

Now that everything is based on nuget packages, how do you work offline?

Starting "dotnet new" and then "restoring dotnet" sometimes uses cached packets and sometimes crashes because it cannot communicate with the nuget server.

+10
source share
3 answers

According to yishaigalatzer (who, according to his Github profile, runs on Microsoft at Redmond): "This is done on purpose. Please do not add logic to get around this." (as part of the discussion of this question: https://github.com/NuGet/Home/issues/2623 )

So..

Here are some ways we can get around this. All this is intended so that "dotnet" does not try to connect to the server, but uses only the local package directory:

(1) Add the NuGet.config file as part of your project (in the same directory as project.json), which removes the online storage from sources. Use the following:

<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> </packageSources> </configuration> 

(2) Use a custom NuGet configuration (for example, "MyCustomNuGet.config") that does not contain sources:

 <?xml version="1.0" encoding="utf-8"?> <configuration> </configuration> 

Then, when you run "dotnet recovery", explicitly specify to use your custom configuration file:

 dotnet restore --configfile MyCustomNuGet.config 

(3) When starting โ€œdotnet recoveryโ€, explicitly specify the local directory of the package as the source:

 dotnet restore -s $HOME/.nuget 

(or where there may be a .nuget directory)

+9
source

To set up a standalone Ubuntu environment for developing .Net Core, I used the following steps: - I downloaded Live USB from Ubuntu to a PC connected to the Internet, and I installed all the necessary packages (dotnet, VS Code, git, node, etc. ); - From the Visual Studio code, I installed the C # extension (as well as others, if necessary); - I successfully compiled and successfully executed ASP.NET Core CLI samples (this downloaded all the NuGet nedded packages); - I copied all the cache packets to the USB drive: - / var / cache / apt - / home /.../. Vscode / extensions - / home /.../. nuget / packages

 * instead of ... should be the username 

On a stand-alone computer:

  • I installed all the packages from the apt folder using dpkd -i * .deb
  • I copied the Visual Studio extension folders to /home/.../.vscode/extension
    • Here I got an error in Visual Studio Code, and I had to grant permissions to folders with the extension chmod -R 777 / home /.../. vscode / extensions
  • I copied all * .nupkg files from nuget / packages to a new folder (e.g. / home /.../ mypackages)
    • to copy only * .nupkg files from the nuget / packages cache folder, which is a whole hierarchy of files and folders, I searched in explorer (Nautilus) ".nupkg" in this cache folder and then copied all * .nupkg files;
  • Now I used the dotnet restore command in different projects using the Nuget package path: dotnet restore -s $ HOME / mypackages

Projects are restored normally, and creating and debugging in Visual Studio Code also works fine.

  • working on npm package cache recovery
+1
source

I recently had this scenario:

  • I had a development machine with an internet connection
  • There was a problem only with the presentation in an environment without an Internet connection

I took $HOME\.nuget\packages from my development computer, sent it through the process for $HOME\.nuget\packages binary files to the environment, and extracted it to the same place in a safe environment.

Then I ran this command:

 dotnet restore --source C:\Users\<my-user>\.nuget\packages\ 

All packages restored. Then I was able to build, develop and repeat as usual.

0
source

All Articles