简体   繁体   中英

Created nuget package's dll can not be accessable from package's loaded project

I want to create a nuget package of my .net core class library.

  1. I copied the nuget.exe file to the root folder of my Solution
  2. Run nuget spec and Solution.nuspec file created. I modified it as below:

     <?xml version="1.0"?> <package > <metadata> <id>Solution</id> <version>1.0.0</version> <authors>cc Team</authors> <owners>cc</owners> <licenseUrl></licenseUrl> <projectUrl></projectUrl> <iconUrl></iconUrl> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description></description> <releaseNotes></releaseNotes> <copyright>Copyright 2017</copyright> <tags>c# .net</tags> <dependencies> <dependency id="NETStandard.Library" version="1.6.1" /> </dependencies> <references> <reference file="Solution.dll" /> </references> </metadata> <files> <file src="Solution.dll" target="lib\\netstandard1.6\\Solution.dll"/> 


file's node src value outpupath of my solution. (bin\\Release\\netstandard1.6\\Solution.dll)

  1. Run nuget pack Solution.nuspec and Solution.nupkg file created.
  2. I put it to my package source.
  3. Create a new .net core class library and select my Solution nuget package from local package source. It added to my project. There is no error or warning. But When I try to access a class from my Solution nuget package, it couldn't be found.I dowloaded 'Nuget Package Explorer' and opened my Solution.nupkg. Icould see Solution.dll and Solution.pdb file under lib --> netstandart1.6.

Then I searched about the error and found this :

"scripts": {
"postcompile": [
  "dotnet pack --no-build --configuration %compile:Configuration%"
]
}

After compile my Solution project it creates Solution.1.0.0-0.nupkg file and Solution.1.0.0-0.symbols. I put it to my local package source but these packages are not listed in the 'Nuget Package Manager'.

Do you have any idea?

My experience is creating package from solution sometimes crappy. Creating the package from the project file could solve the problem.

After I clean 'C:\\Users\\XXX.nuget\\packages\\Solution' folder and add package again fix my problem.

Because there is bad formatted nutget package which I tried before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM