I have the .NET 5 SDK installed, but I do not have Visual Studio installed.
Whenever I tried to perform a tool installation, example dotnet tool install -g csharprepl, it always results in:
error NU1100: Unable to resolve 'csharprepl (>= 0.0.0)' for 'net5.0'.
error NU1100: Unable to resolve 'csharprepl (>= 0.0.0)' for 'net5.0/any'.
The tool package could not be restored.
Tool 'csharprepl' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
How do I use dotnet tool install in the absence of Visual Studio?
I had this same problem from a fresh install of win10/.netcore (without Visual Studio) - it seems that the default NuGet.config doesn't have the package sources setup by default (at least for me).
To resolve this, I added the following packageSource config at %AppData%\NuGet\
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
Edit: Additionally, you may need to download NuGet.exe to a tools folder, and add this to your PATH to use nuget.
Related
I have a package config file for a project this
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Stylesoft.Common.Dev" version="1.0.1.0" targetFramework="net461" />
</packages>
And the package dll is referenced like this in csproj file
<Reference Include="Stylesoft.Common.Dev, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\SharedPackages\Stylesoft.Common.Dev.1.0.1.0\lib\net40\Stylesoft.Common.Dev.dll</HintPath>
</Reference>
Earlier this used to work because nuget used to restore the package in this folder Stylesoft.Common.Dev.1.0.1.0 but I don't know what was changed but now nuget skip the revision number of version, now it creates folder with name Stylesoft.Common.Dev.1.0.1 skipping last zero and so I get compile error, because the project tries to check dll in this path
..\..\..\..\..\SharedPackages\Stylesoft.Common.Dev.1.0.1.0\lib\net40\Stylesoft.Common.Dev.dll
I am not able to figure out what was changed and how to make it restore package in the same folder structure as earlier
Any help would be appreciated!
I was suffering the same problem. The cause will either be that the nuget.exe version has been updated and now downloading packages excluding the revision in the path, or that a change has occurred where the packages are hosted. Not sure which for myself as this happened when migrating source from TFS to Azure DevOps. So the build pipeline is different and the packages are on a new feed.
I feel the best solution is to make the projects in Visual Studio work locally the same way the server build expects them to. So as it is looking for packages in folders excluding the revision number in their name, that's where they should be.
So the fix is to reinstall the packages using the same feed and nuget client. The visual studio package manager should install the packages to the correct location. So you can either ensure that you have the correct versions, or just hope it will be ok and continue with the following:
Delete all of the packages from the packages folder (hopefully all your projects use the same folder otherwise this may be laborious).
Clear your nuget package cache from visual studio (there's a button to do this under Tools -> Options -> Nuget Package Manager)
In visual studio, open the nuget package manager console.
Run 'Update-Package -reinstall'
It may take some time depending on how many packages and projects you have, but this will hopefully ensure your project reference hint paths will match the packages' installed locations.
I have ported a .net application to .netcore and want to publish it as a self-contained application. Unfortunately, this does not work:
dotnet publish -r win-x64
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
<Path>\IPLauncher.csproj : error NU1100: Unable to resolve 'Microsoft.NETCore.App.Runtime.win-x64 (= 3.1.2)' for '.NETCoreApp,Version=v3.1'.
<Path>\IPLauncher.csproj : error NU1100: Unable to resolve 'Microsoft.WindowsDesktop.App.Runtime.win-x64 (= 3.1.2)' for '.NETCoreApp,Version=v3.1'.
<Path>\IPLauncher.csproj : error NU1100: Unable to resolve 'Microsoft.AspNetCore.App.Runtime.win-x64 (= 3.1.2)' for '.NETCoreApp,Version=v3.1'.
Restore failed in 179,65 ms for <Path>\IPLauncher.csproj.
In case it is important, my csproj-file looks like this:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
</Project>
Edited to add: The weirdest part is that my colleague can publish a self-contained exe for the same project with identical configuration - so it seems to be some problem with my configuration.
It seems like nuget restore command for your application can't restore some packages.
There are many reasons for that, but you can do basic research for determine why it's heppens. Here some tips:
Clear all NuGet caches dotnet nuget locals all --clear
Check if NuGet packages you trying to restore accessible from nuget.org website. Official nuget package manager website has different API's (v2/v3) so you must check you use latest version of API.
If you use NuGet package not from official portal - verify that NuGet server you use for restoring nuget packages is accessible.
These settings placed in default nuget.config file here: %appdata%\NuGet\NuGet.config
Note that if you using custom nuget.config for your project/solution it's overrides default nuget settings. This file can contains some settings that breaks restore command. So check it out first.
After upgrading to .Net Core 3.1 in my Web API Project I tried this usual ef command -
dotnet ef
Got:
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Then found this - dotnet ef not found in .NET Core 3
Therefore, tried:
dotnet tool install --global dotnet-ef --version 3.0.0
and got:
/usr/local/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v2/index.json
/usr/local/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Response status code does not indicate success: 400 (Bad Request).
The tool package could not be restored.
Tool 'dotnet-ef' failed to install. This failure may have been caused by: ...
How to fix?
Found this -
Nuget connection attempt failed "Unable to load the service index for source"
So, then opened Nuget.config on MAC -
~/.nuget/Nuget/Nuget.config
And deleted all the URLs from in there.
Re-running
dotnet tool install --global dotnet-ef --version 3.0.0
Worked :)
On re-using NUGET in a VS for MAC project (just added any Nuget), I was just left with
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<packageSources>
</configuration>
Finally, realised had used ef tools 3.0.0, so finished updating ef tools with -
dotnet tool update --global dotnet-ef
While building a solution cloned from a working repository, I'm getting the below error. Infact the url https://tc.xxx.yyy.intra/httpAuth/app/nuget/v1/FeedService.svc/ is correctly added as a package source in NuGet(according to Visual Studio).
https://tc.xxx.yyy.intra/httpAuth/app/nuget/v1/FeedService.svc/: Unable to load the service index for source https://tc.xxx.yyy.intra/httpAuth/app/nuget/v1/FeedService.svc/.
An error occurred while sending the request.
The remote name could not be resolved: 'tc.xxx.yyy.intra'
https://api.nuget.org/v3/index.json: Package 'ServiceLocatorAnalyzer.1.0.6533.24990' is not found on source 'https://api.nuget.org/v3/index.json'.
https://www.nuget.org/api/v2/: Package 'ServiceLocatorAnalyzer.1.0.6533.24990' is not found on source 'https://www.nuget.org/api/v2/'.
. Please see Error List window for detailed warnings and errors.
But, upon checking the NuGet.config file(below) in my AppData folder, I can see only 1 NuGet package source is added in it whereas according to VS there are 5:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Is this an expected behaviour?
I also deleted, the NuGet.config file; restarted my VS as someone mentioned here VS2015 nuget package manager not finding packages but it didn't work.
Any idea where I'm going wrong?
As specified in the how settings are applied documentation, many nuget.config files can be read. One of them is specifying the additional source.
If you download nuget.exe from nuget.org/downloads and use nuget restore, it should list all the nuget.config files that apply, although that might only happen if no fatal error occur (and I'm not sure if a source being unreachable is fatal). If so use dotnet new nugetconfig if you have the .NET Core SDK installed, as the nugetconfig template clears all other configs sources and adds only nuget.org. THen when you restore (use dotnet restore -v n if you have a .net core project because the default verbosity is minimal), all the nuget.config files will be listed, even if their sources are not.
Once you have the list of nuget.config files that were used in a restore, open them one by one until you find the one that defined the bad package source.
I am trying to install the Nuget package for the sqlite3.exe command line program in a C# project targeting Framework 4.7.2. The package is:
https://www.nuget.org/packages/sqlite3-command-line-shell/
When I try this from within VS2015 it errors out with:
Could not install package 'sqlite3-command-line-shell 1.0.1'. You are
trying to install this package into a project that targets
'.NETFramework,Version=v4.7.2', but the package does not contain any
assembly references or content files that are compatible with that
framework.
Now, this package literally only installs the .exe file. There are no .NET dependencies whatsoever. So I don't see the rationale for this error.
Is there something wrong with the Nuget package? Or is there an option I've missed to work around this maybe?
The NUSPEC file inside the NUPKG file contains:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>sqlite3-command-line-shell</id>
<version>1.0.1</version>
<title>sqlite3 command-line shell</title>
<authors>Darren Hale</authors>
<owners>Darren Hale</owners>
<licenseUrl>http://www.sqlite.org/copyright.html</licenseUrl>
<projectUrl>http://www.sqlite.org/index.html</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The sqlite3 command-line shell program.</description>
<releaseNotes>Version 3.8.10.2 (x86) of sqlite3 command-line shell program.
Removed unnecessary files accidentally included when packing .nuspec file.</releaseNotes>
<copyright>Copyright 2015</copyright>
<tags>sqlite3 cli shell exe</tags>
</metadata>
</package>
I don't see any mention of any .NET anything; but I know very little about how Nuget packages are constructed.
The sqlite3.exe is in the root directory of the NuGet package.
It looks like you are trying to create a tools NuGet package, similar to say NUnit.ConsoleRunner. the executable would need to be in a tools directory inside the NuGet package.
The .nuspec is missing a files section, something like:
<files>
<file src="sqlite3.exe" target="tools" />
</files>