Now that everything is based off of nuget packages, how do you do offline development?
Running dotnet new
and then dotnet restore
sometimes uses cached packages, and sometimes fails because it can not contact the nuget server.
They are designed to allow them to be installed side-by-side. However you do need to install the . NET Core runtime onto the server to allow the code to be run because the OS has native dependencies that need to be present. See this link for more information.
NET Core can be installed in two ways: By installing Visual Studio 2017/2019 or by installing . NET Core Runtime or SDK.
With the latest launch of ASP.NET Core, Microsoft too walked the path of Windows to provide users with the option of web application development on other platforms. The high-performance, cross-platform, open-source framework features, cutting-edge functionality allows to building cloud-based web applications.
According to yishaigalatzer (who, according to his Github profile works for "Microsoft" in "Redmond"): "This is by design. Please don't add logic to work around it." (as part of this issue report discussion: https://github.com/NuGet/Home/issues/2623)
So ..
Here are some ways we can then work around it. All of these are intended to stop "dotnet" from trying to connect to the server, and to use the local package directory only:
(1) Add a NuGet.config file as part of your project (in the same directory with project.json) that removes the online repository from the sources. Use the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
(2) Use a custom NuGet configuration (eg. "MyCustomNuGet.config") that includes no sources:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>
Then when you run "dotnet restore", explicitly specify to use your custom configuration file:
dotnet restore --configfile MyCustomNuGet.config
(3) When running "dotnet restore", explicitly specify the local package directory as the source:
dotnet restore -s $HOME/.nuget
(or wherever the .nuget directory may be)
To setup an offline Ubuntu environment for .Net Core development I've used the following steps: - I've booted a live USB with Ubuntu on a PC connected to Internet and I've installed all necessary packages (dotnet, VS Code, git, node etc.); - From Visual Studio Code I've installed C# extension (and also others if necessary); - I've compiled and ran ASP.Net Core CLI samples with success (this downloaded all NuGet packages nedded); - I've copied on a USB stick all packages caches from: - /var/cache/apt - /home/.../.vscode/extensions - /home/.../.nuget/packages
* instead of ... should be the username
On the offline computer:
The projects have restored ok and building and debugging in Visual Studio Code is also working ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With