Visual Cobol 2012 and Nuget - nuget

I'm developing a DLL using Visual Cobol 2.2, and I want to make it a NuGet package so that other people in my shop can leverage it. In my VC project, the first time I tried to do this, I right-clicked on References and clicked on "Manage NuGet Packages." I received a message along the lines of "Not compatible with project." Not sure of the exact message text because I only got it once. After that, if I right-click on References, I do not even get the "Manage NuGet Packages" option. If I try to add the Nuget package at the solution level, I get a message "...could not be installed because it is not compatible with any project in the solution."
What am I missing? Is there something I need to do to the project properties for it to support NuGet? Something with the NuGet configuration? Something to the VC config?
Thanks for the help,
Mike

Related

How to list missing NuGet packages

In a large VS2013 solution the packages.config has got out of sync, and the following message is displayed in the package manager:
Is there a NuGet powershell command to list these packages so I can manually remove them from the packages.config?
You can open the solution in Visual Studio. Go to the Solution Explorer panel. Look for the yellow warning signs next to the missing assemblies in under References in your project.
OR
You can try building the solution. It will generate some errors and you can deduce the dlls which are missing.

How to manage nuget packages without opening solution

I am unable to load my solution ever since I upgraded my nugget packages to the latest Xamarin.Forms alpha.
Can someone provide me an example of how I can point all nuget packages of a certain id to an earlier version without having my solution open?
I think the best way is to open the packages.config file in a text editor and remove the Xamarin.Forms values from it.
After that you can open your .csproj file (with a text editor) and also remove the references from it.
Now you should be able to open the project (with the visual studio) and add the references you want again via the nuget manager.

Entity Framework NuGet package not source-controlled/in TFS?

I mapped my solution (using Entity Framework) onto a new PC. The solution reports a compile error because the EntityFramework.dll can't be found. Digging deeper it seems that TFS only stores the packages/repositories.config file in source control. I'm unable to re-add the Entity Framework as VS2012 reports it as already installed (green tick).
What's the normal process to fix this? Is this a wider issue with source-control and NuGet packages? Should I just add the DLL to source control?
FYI, the HintPath is for the project is: ..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll which of course doesn't exist.
My current workaround is to hack the 'packages.config' to delete the EF item and then go back into the NuGet dialog.
If you right click your solution you should have the option to "Enable NuGet Package Restore" - this should sort your issue out.
You may also need to right click your solution and got to "manage nuget packages etc..." - it may give you an option to restore missing packages.

NuGet Source Control Integration

I checked out my project using git and saw the assembles I installed with NuGet as missing. I tried building and got a missing assembly error so I tried to re-add it with NuGet but NuGet says I have added that dll/reference to my project (it has a green checkmark).
I went into the options and checked get missing ref during build and did a rebuild and I am still getting missing asm errors.
How do I use NuGet with source control?
Right Click Solution (and projects) -> Enable NuGet Package Restore
or...
Check the packages folder into source control.
YMMV, NuGet is terrible at integrating with source control.
What exact error are you seeing with package restore ?
http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages - has more details around enabling package restore.
[For the benefit of those who land here via a web search]
As of NuGet 2.0, "Restore Packages" is a step that can be performed by the build before attempting to build your solution:
See this from official NuGet docs
Enabling package restore for a solution can be done through Visual Studio GUI and the changes made to the project are similar to what #Precipitous suggests in his comment. In essence you do this:
Right click on the solution in Visual Studio and click "Enable NuGet Package restore".

Problem with uninstalling NuGet Packages

I'm trying to uninstall some packages installed by NuGet. According to the doc described here, I should see an Uninstall button (first screenshot below) when I select the installed package. However, I only see a Manage button (second screenshot below). Can anyone please tell me how to uninstall the packages?
If you scroll down to the Managing Installed Packages section of the NuGet documentation page you linked to you will see the Manage button and an explanation.
In NuGet 1.4 a new feature was introduced allowing you to select the solution in the Solution Explorer and add/remove packages from multiple projects in one step. Previously you had to select each project in the Solution Explorer and add/remove the package from each project one at a time.
If you click the Manage button a Select Projects dialog will be displayed where you can uncheck the projects that you want the NuGet package to be uninstalled from.
If you select the project instead of the solution in the Solution Explorer you can add/remove packages from that selected project. In this case you will only see the Install and Uninstall buttons.
Finally, I found I had to manually edit the .sln solution file and remove these lines:
GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.Interception.2.1.505.0\lib\NET35;packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35;packages\EnterpriseLibrary.Data.5.0.505.0\lib\NET35
EndGlobalSection
After removing the above lines in the solution file, those packages disappeared in the NuGet Packages Window "Installed package" page. There is only one package left and I can now see the "Uninstall" button.
EDIT:
I also had to delete the packages folder in my solution directory.
Sometimes there are dependencies that disallow uninstalling a package, but you need to do so anyway (i.e. if you inadvertently install two different versions of a package with dependencies).
When this happens, the only way to uninstall the packages is to force the uninstallation, and this can only be done through the Package Manager Console.
Before going to the Console, you should open the Manage NuGet Packages window, and note down the Id and Version of your package, which appears on the right pane when you click on the package.
Then you can close the Manage window, and open the console (Package Manager Console), and run this command:
uninstall-package -Id YourPackageId -Force -Version YourPackageVersion
Note the -Force parameter. For example
uninstall-package -Id Unity -Force -Version 3.0.1304.0
This command allows to uninstall the version 3 when it is installed in parallel with version 2, which can't be done throgh the Manage window.
I had similar issues recently. My project worked fine but I couldn't add or remove any packages via the NuGet package Manager anymore because EnterpriseLibrary 5.0.505 was shown as missing from the source. But trying to either restore or delete it failed with an error "unable to find version '5.0.505. of package 'EnterpriseLibrary'".
I traced this down to having the following reference in the packages.config file:
<package id="EnterpriseLibrary" version="5.0.505" targetFramework="net4" />
Comparing this with other solutions to which I added the package more recently I changed it to, the following, which fixed the issue:
<package id="EnterpriseLibrary.Common" version="5.0.505.0" targetFramework="net4" />
I never edited any package.config files manually, so I don't know how the mismatch happened. Maybe the reference changed since originally including the package without updating the config file...?
I had a problem to remove Code first lib CTP5 that had dependences, uninstall did not return any message and did not remove anything. Delete references from packages.config that you need to remove. After that it will not show in nuget anymore and you can reinstall or continue without.
After using the VS IDE Manage NuGet Packages dialog or Package Manager Console you may have to manually remove solution files or other files on the file system that are part of the package not in the packages folder.
I was evaluating the Microsoft.AspNet.FriendlyUrls package which added a master page, a user control, a class code file and a packages.config file to my ASP.NET web application project / solution. I made the mistake to manually undo / remove these files from the solution before using the NuGet Packages dialog to remove the package. Everything got confused at that point.
As others have said, deleting the packages folder was the solution. But then I had to manually figure out the other files outside that folder that also should be deleted.