I have two entity framework solutions in Visual Studio 2012. I used Nuget to download EF5 on both.
In first solution/project I created a class library and I want to add it to the project in solution 2.
I am not sure how to add it. I noticed that there is a folder
..\..\packages\EntityFramework.5.0.0\lib\net45
Two questions:
Where is the folder(packages) coming from? (Just a guess it is from Nuget but not sure..)
How to add the reference?(Browser to this folder to locate it or using Nuget?)
First: It's one folder up to your project folder and actually it's beside your solution, it has been downloaded from http://wwww.nuget.org website.
Second: Add it through NuGet(by clicking on project and select Manage Packages or using the command line power-shell Install-Package) and it will manage it to not download it again and reference to the same file
Related
I have 2 projects: A & B that I want to publish as NuGet Packages but I don't know how to develop efficiently in Visual Studio.
Solution 1
Project A
Project B - references Project A as NuGet reference
When I make a change to Project A that is needed in Project B do I have to publish Project A? Is there a way to get the project reference functionality during development? Maybe Project B shouldn't reference Project A via NuGet?
There must be a good way to handle this situation, no? I've reviewed the NuGet docs but I couldn't find anything. There must be docs/blogs/SO posts to read more about this... I'm struggling to come up w/ the right keywords.
You might want to look at this extension: NuGet Reference Switcher for Visual Studio 2017
This allows you to switch between NuGet packages and project references during development.
Check out this blog post: https://markheath.net/post/multiple-nuget-single-repo
Basically, dotnet pack handles this for you automatically. You use regular project references when developing.
There must be a good way to handle this situation, no?
The best solutions is that the project-to-project reference should be recommend when the referenced project is modified frequently, the nuget reference is more appropriate when share the reference project to others or publish it. Just like NuGet Reference Switcher doing.
For some more detailed info, you can check following thread:
nuget packages in local work
NuGet has many advantages as a package manager for the Microsoft
development platform, this does not mean that it is not flawed. Just
as you encountered, if the referenced project is modified frequently,
we have to rebuild it, build nuget, publish it for each modification.
That will bring a lot of boring work. To resolve this disadvantages,
the Project-to-project references should be a better way.
The
advantage of a project-to-project reference is that it creates a
dependency between the projects in the build system. The dependent
project will be built if it has changed since the last time the
referencing project was built. A file reference does not create a
build dependency, so it is possible to build the referencing project
without building the dependent project.
You could add following Post-build event command to pack your project after building.
"the nuget.exe path\nuget.exe" pack "project path\NuGetPackageLibrary.csproj" -OutputDirectory "Your target path"
When your build successful, the package in target path will be replaced by the latest version.
I have a solution in Visual Studio 2013 with more C# project files that have source code in common but are targeting for different platforms (.Net, WinRT, .Net Micro Framework and so on).
All the csproj files are under the same directory.
These projects use a Nuget package that is available for all the above platforms itself.
If I add this Nuget package for one of the project (ex. .Net), the package.config file is created and inside has reference to that target (ex. .Net). The package is downloaded in the packages folder.
If I try to add the same package but for a different target to another project in the solution, the UI tells me that the package is already installed. It's true because a package.config file is already there but I'd like to have the same package for a different target.
So my question is the following : how can I add the same Nuget package to all different projects but with different targets ?
Thanks,
Paolo
Unfortunately, I don't think NuGet supports your scenario.
NuGet expects the packages.config file to be in the same folder as the .csproj file. There should be a 1-to-1 relation between these files. You should create a separate folder for each project rather than keep all .csproj files in the same folder.
If you want to share code across multiple projects, the easiest way is to use the new Shared Project support in Visual Studio. Normally this only applies to Universal Projects, but there is an extension[1] that you can install that enables Shared Projects for all project types.
Simply create a new Shared Project. Add all you common code to it. Then in your platform specific projects, you can simply Add Shared Project Reference.
Since each project is now independent, NuGet will add the appropriate package.
Hope this helps. Good luck!
[1] Shared Project Reference Manager https://visualstudiogallery.msdn.microsoft.com/315c13a7-2787-4f57-bdf7-adae6ed54450
I have created a NuGet gallery in my company.
I want to create and publish a solution level NuGet package.
Everyone who will install the package will not get a dll but an entire project added to his/her visual studio solution.
Just like adding an existing project, the user will get a project with source code classes and everything is ready to use.
Just build it and use it.
I know it's possible, but couldn't find any documentation.
Anyone?
It is possible to add any files (not only .dll) and even directory structures to a NuGet package, so in theory you could store all files belonging to a project in a package and publish that. However, it is only possible to install NuGet packages into an existing project, meaning that you won't be able to add the packaged files as new project to any solution. In addition, the contained files will be put to the solution's packages folder, not to a solution or project folder.
As an alternative, consider creating a Template project instead of a NuGet package, as explained in How to: Create Project Templates and my blog post Creating template projects. This will result in a .vsix file that any developer can install as Visual Studio Add-In, the templated project will then appear in Visual Studio's File -> New -> Project... dialog as new project type and can be added to any solution.
Similar to your NuGet gallery, it is also possible to create a private Visual Studio Gallery to share such Add-Ins within, for example, a company, as explained in this MSDN article.
I'm trying to create a nuget package that contains my "starter project". This is a project which I use to start every Umbraco project.
This starter project has the following structure:
Solution:
Umbraco project
CustomControls project
In short, I want Nuget to:
1) download a specific version of Umbraco, and put it in the Umbraco project folder
2) Add the CustomControls project
I can put the CustomControls project in the "Content"-folder, but I can't get the Umbraco project in my solution at the top level. Right now, NuGet seems to create this:
Solution:
Umbraco project => CustomControls project
So the CustomControls project is inside the Umbraco project, which doesn't serve my purpose as it has to remain separate.
So two seperate projects inside one solution.
How do I go about this?
One of the parameters in Install.ps1 is called $project, and it is a reference to the EnvDTE Project object for the project into which your package has been installed. You should be able to call DTE.Solution.AddFromFile() to add another project to the solution.
I have been trying to use NuGet in a complex solution (with around 100 project files) and been struggling with updating the existing references (from a /ext/.. directory ) to that of official NuGet directory. As far as I understand we need to manually select the project files (from the PackagaManager GUI/Manage Assemblies) and update the references. This is cumbersome to know which project uses what out of 100 odd projects. Is there any way (built-in to nuget or any other workaround) to update assemblies to nuget directory without having to manually select projects?
This is not supported as yet and I've registered an issue under codeplex's nuget project.