I have a .NET Framework class library project that I'm turning into a nuget package and uploading to my own nuget server.
This is how the project looks:
Really simple, just a single .cs file with a few classes.
I'm compiling the code with Debug configuration and Any CPU platform.
Produced files are the following: Synteco.ScriptInterpreter.dll and a .pdb file with the same name
In the directory of my .csproj file I also have a .nuspec file, which looks like this:
I'm only copying the Synteco-Icon.png file in the images folder in the final .nupkg in order to set the icon for my nuget package.
Upon running nuget pack I'm getting the following output
As we can see, everything seems to be in order.
However, if we look into the produced .nupkg file, its contents are:
Somehow the folder content has been created. In the past this folder was not created at all.
I am able to push this nuget package to my server, but when I download it via Nuget Package Manager in other projects, everything from the content folder is being copied into the project that is trying to use that nuget package. For larger packages this becomes a real issue and unwanted files are being copied to projects.
What is the issue and how can I stop the content folder from being created?
I've tried running nuget pack [NAME_OF_MY_NUSPEC_FILE] but that would produce something even more strange. Take a look:
Am I doing something wrong?
P.S.
As far as I'm concerned, this is how a proper nuget package should look like. This is Newtonsoft.Json:
Problem was solved!
Silly me, I actually had some files with build action set to Content in my C# project for my nuget packages!
Upon removing all items with that build action the content folder is gone!
Related
So I do have following set up:
A project which is turned into a .nuget package. Let's call it provider.csproj turned into provider.nuget. Also, there are some .json files that need to live with .dll in the /lib folder of the package. I achieved this by copying those .json files into the package /lib folder by explicit instructions in the provider.nuspec files which look like following:
<files>
<file src="required.json" target="lib/netstandard2.0">
</files>
Now that code ensure that when Provider.nuget package is generated, there is in fact a required.json file copied with the output .dll and everything works fine.
I can actually reference this nuget package in another project, which for now lets call it consumer.csproj
That works great too. So basically if I have to run consumer.csproj as it is then, there are no issues. It goes to .nuget/packages folder and finds my package there and executes all fine.
Problem occurs when I try to publish consumer.csproj. When I run dotnet publish on the project it copies provider.dll and it does not copy required.json with it.
How can I tell Consumer project to copy required.json file locally in its /bin folder when I reference provider.nuget package?
I have library "library.dll" where is something like that in the code:
PathModifier.AddEnvironmentPath("lib\\dlls", PathModifyMode.RelativeToProjectDirectory);
In this "dlls" folder are *.dll files (cca 20 files) which need to be added to Environment path. Properties of these files are set up like this:
Copy to Output Directiory: Do not copy and
Build Action: Resource
Library has about 30 MB, so dll files are contained in.
When I use this library in WPF project, there is problem, because
it try to find "lib\dlls" in WPF project directory instead of inside the "library.dll".
Is there any solution, how to say "find dlls folder only inside library, not in project, where is library used"?
Thanks.
If you are trying to centrilize the dependencies, then you should take a look at my answer here Nuget common folder. The idea is the same as saving all Nuget packages, all your dependencies should point to the same place, on this case the Common folder. On the Nuget scenario, you need to add an extra configuration to restore all packages from there and seed the nuget repository from that location.
In your case I think that the WPF project is looking inside the bin folder, and because you have the resources as Do not copy, then you can't find them inside, if you change that Copy Always will bring those dependencies inside your bin folder.
I've tried almost everything found on the net to solve this problem, but it just seems to not work!
I created a .exe file from a visual studio 2013 project using wpf. I want this file to create pdfs, so I added as references .dlls concerning itextsharp.
Everything works fine if I keep my .exe file in the same directory as itextsharp's .dlls. But when I try to run the .exe outside, the program crashes.
I've tried to use ILMerge, I read it is pretty good to merge .exe and .dll, but when I double-click one the newly-created .exe file nothing happens.
The command I wrote in my command window, once in the ILMerge folder, was:
ilmerge C:\Users\Utente\Desktop\PDFWriter.exe C:\Users\Utente\Desktop\itextsharp.dll /out:C:\Users\Utente\Desktop\merged.exe /target:winexe /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5"
Thanks for your help!
Use Fody.Cosura project for merging. A lot nice to work with than ILMerge.
All you need to do is to install nuget package in your project:
PM> Install-Package Costura.Fody
And you are pretty much done. You can adjust the configuration, but that is not always required as just installing the package does the bulk for you.
I am facing issue while packaging static content as part of NuGet.
I want to package Javascript files only as part of the NuGet package. Included the following entry inside the NuSpec file as shown below...
file src="*.js" target="Content\JS"
Included the csprok and corresponding NuSpec file inside the .Proj file.
Now when i try to run the following command (msbuild packaging.proj) it gives out the error saying
error : Failed to build package. Ensure '...NuSpec' includes source and symbol files
Not sure if i am missing something here...
Any help is appreciated.
Thanks
Finally figured out that we can use "NuGet Package Explorer" to create a NuGet package. This way we can add the static content only and it doesn't thrown any issues i was facing earlier.
I have a solution with many projects. There is actually a Core project and a few plugins. I changed OutputPath for all plugins so all binaries end up in the Core bin\debug folder. (this is necessary as the Core do not have a reference on plugins, hence it does not "include" plugins binaries when it is compiled.)
So basically my folder structure is as follow:
Solution
MySolution.sln
Plugin1\
Plugin2\
Core\bin\debug
Each plugin OutputPath is "..\Core\bin\debug". When I open the solution Visual Studio creates a folder "Core\bin\debug" in Solution's folder parent as if the relative path starts from .sln file. However when I build the solution the binaries are output to the correct path ("Solution\Core\bin\debug").
Core\bin\debug
It looks like a Visual Studio bug to me, but maybe I overlooked some option somewhere. Any ideas how to resolve this problem ?
PS: I know this not a critical issue as everything build and works fine, however I dislike the idea of meaningless folder hanging around
Rather than changing the output location of the plug-ins, what you could do is create a post-build script (Properties \ Build Events tab) for them that will copy the them to the Core folder. That would prevent the confusion with output folders.
This command line should do the trick for you:
copy "$(TargetPath)" "$(SolutionDir)Core\$(OutDir)"
If you need to copy .pdb and .config files as well, you can add more lines:
copy "$(TargetPath).pdb" "$(SolutionDir)Core\$(OutDir)"
copy "$(TargetPath).config" "$(SolutionDir)Core\$(OutDir)"
If you really want to do it with a single line, this should also work, though it's not as clean:
copy "$(TargetPath)*" "$(SolutionDir)Core\$(OutDir)"
If you're not using the same output path in both the main project and the add-ons, you'll need to replace $(OutDir) with a hard-coded value. If you have them set to target the typical "\bin\Debug" folder (or have just left the defaults in place), then you can get away with using the $(OutDir) value.
Instead of using "..\Core\bin\debug", use "$(SolutionDir)\Core\bin\debug".