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>
Related
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.
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.
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 have encountered a weird behavior with VS for Mac. This is how I repro it:
Built a .NET Standard 2.0 NuGet package using VS2017. Package is called "MobileApps.Auth 1.0.0"
Pushed the NuGet to our company NuGet server
Switched over to the Mac and launched VS
On the Mac; Built a Xamarin Forms app (shared project is also .NET Standard 2.0)
Added reference to the .NET Standard 2.0 NuGet
ERROR:
Package MobileApps.Auth 1.0.0 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package MobileApps.Auth 1.0.0 supports:
- monoandroid81 (MonoAndroid,Version=v8.1)
- xamarinios10 (Xamarin.iOS,Version=v1.0)
I have zero clues as to why the NuGet would support monodroid81 and xamarinios10. It's a .NET Standard 2.0 library that reference Xamarin.Forms.
If I instead remain on the PC and run steps 4 and 5 in Visual Studio 2017 all is peachy.
This smells like a bug in VS for Mac. Has anyone else seen this?
Overall, having spent a few days building NuGet packages, based on .NET Standard 2.0, both on the Mac and PC I get the overall feeling this doesn't really work on the Mac. The reason I built the NuGet on VS2017 is because NuGet packs built on VS for Mac includes all kinds of facades that causes msbuild to fail due to conflicts (same identifiers found in multiple referenced assemblies).
[EDIT 1]
This is the NuGet layout when package built on VS4M:
_rels (empty folder)
[Content_Types].xml
lib
netstandard2.0
MobileApps.Auth.dll (my lib)
(+ 113 other dlls)
MobileApps.Auth.nuspec
package
services
metadata
core-properties
5bd1f861cd8a425f854c073a4a5f3e0e.psmdcp
And this is the NuGet layout when built on VS2017:
_rels
.rels
[Content_Types].xml
lib
netstandard2.0
MobileApps.Auth.dll (my lib)
MobileApps.Auth.nuspec
package
services
metadata
core-properties
5bd1f861cd8a425f854c073a4a5f3e0e.psmdcp
The difference is that VS4M includes 113 extra dlls in the netstandard2.0 folder while VS2017 doesn't. How can I control that?
[EDIT 2]
This is the .nuspec from within the .nupkg, built with VS4M:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>MobileApps.Auth</id>
<version>0.1.1</version>
<title></title>
<authors>Jonas Rembratt</authors>
<owners>Jonas Rembratt</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>bla bla</description>
<summary></summary>
<releaseNotes></releaseNotes>
<copyright></copyright>
<language></language>
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Xamarin.Forms" version="3.1.0.697729" />
<dependency id="System.ValueTuple" version="4.5.0" />
</group>
</dependencies>
</metadata>
</package>
Ok, here's the latest outcome from my experiments with NuGet/VS4M/VS2017. One problem seemed to be that VS4M included 113 libs in the NuGet package so I wanted to see if that was the problem or not. I first tried to simply renamed the .nupkg file into .nupkg.zip on the Mac, then unpack it, then remove the .nupkg, then remove the 113 libs in lib/netstandard20 leaving only my own dll in there. I then simply compressed the folder again into "MobileApps.Auth.nupkg.zip" but it seems Finder won't take kindly to then simply removing the ".zip" suffix. So, I simply moved the .zip over to Windows and removed the ".zip" suffix there before moving it back to MacOS. In the end I'm left with a .nupkg that in essence looks just like the one I generated with VS2017 (see OP), that is a package that contains only my own .dll file.
This works.
So, the problem now is that:
This leaves me with having to go through a tedious process of manually removing all unecessary .dll files from my NuGet package whenever I re-generate it. Is there really no way to configure the 'nuget' build to exclude these libs in the first place, like VS2017 does?
Why didn't it work when I built the .nupkg file on VS2017 and then tried to use it with my projects in VS4M?
I have a solution and this solution contains a asp.net web site (not application).
I want to enable C# 6, so have to install nuget packages. I did this in Visual Studio 2015, it creates C:\solution\website\packages.config.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.7" targetFramework="net45" />
<package id="Microsoft.Net.Compilers" version="2.3.2" targetFramework="net45" developmentDependency="true" />
</packages>
I want to follow the best practice that do not add the package binaries into version control system, so I only committed packages.config.
It seems automatic package restore doesn't work for web sites, so I plan to write a svn update script, that whenever I run svn update, the script will run to restore packages in case other developers ran svn clean that deletes unversioned files.
In the script I write
nuget.exe restore C:\solution\Website\ -PackagesDirectory C:\solution\packages
the command does download missing packages, but it doesn't install the packages.
Does anyone know why? Am I missing anything?
For NuGet 2.7+: Downloads and installs any packages missing from the packages folder.
Restore packages for a solution file
nuget restore a.sln
Restore packages for a solution file, using MSBuild version 14.0 to load the solution and its project(s)
nuget restore a.sln -MSBuildVersion 14
Restore packages for a project's packages.config file, with the packages folder at the parent
nuget restore proj1\packages.config -PackagesDirectory ..\packages
Restore packages for the solution in the current folder, specifying package sources
nuget restore -source "https://www.nuget.org/api/v2;https://www.myget.org/F/nuget"
For more info