简体   繁体   中英

My NuGet package doesn't seem to update in projects that use it as a dependency

Forgive what must be a very simple oversight on my part but I simply cannot get this to work as expected.

I am building a .NET Framework 4.6 Class Library that needs to be downloaded by other applications from a private nuget repository. Here is my process:

  1. I have a test project, ConsoleApp5. It has a simple main function in it.
  2. I download my NuGet package, MyPackage (right click on project and click Manage NuGet Packages, select appropriate repo and package, click install.)
  3. I run my test. In this case, I'm simply trying to instantiate a class, something not difficult. I'm getting an error about class accessibility.
  4. Back in MyPackage, I replace all instances of the word protected with public . I add a new class as well by right-clicking on the project, selecting Add Item, targeting a class and giving it the name TestClass .
  5. I go to Project > MyPackage Properties... > Application (tab) > Assembly Information, and I manually update the version patch number by one. So now it is 1.0.5.
  6. I go to the project directory in the Developer Command Line and run the following command: C:\\Users\\jptak\\Downloads\\nuget.exe pack -Version 1.0.5
  7. Then I run the following command to push the update (Success message: Your package was pushed. ): C:\\Users\\jptak\\Downloads\\nuget.exe push MyPackage.1.0.5.nupkg MySecretCodeGoesHere -src http://my.nuget.server.goes.here.com
  8. I go back to ConsoleApp5, Manage NuGet Packages, see the update in the appropriate package, and click the update arrow. The download completes and the new version number is there.
  9. I go to use new classes or check that old errors are fixed and all of my tests fail. TestClass is not there.

This leads me to believe that the code I am writing is not making it to the NuGet server. Does anyone know what I am missing from this process to make the most recent version of the code get updated on the server?

This process is foreign to me as I am not a .NET developer (I work with PHP mostly).

Here are some more pieces of information about my IDE settings:

  • In Build > Configuration Manager... > Debug has been switched to Release
  • I have tried building, rebuilding, and cleaning my project. I haven't seen that any of these processes has had any effect on the code being pushed at all.

Here is the code from my ConsoleApp5:

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            string testclient = "testclient";
            string testpass = "testpass";
            string scope = "validate-contract";
            string accessToken = "";
            string retrievedScope = "";

            MyPackage.TestClass test = new MyPackage.TestClass();
        }
    }

Error: TestClass does not exist in namespace. Did you forget an Assembly Reference?

Here's the TestClass code in MyPackage:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyPackage
{
    public class TestClass
    {
        public TestClass()
        {

        }
    }
}

The NuGet server I'm using is: https://github.com/Daniel15/simple-nuget-server

EDIT 1 Upon inspecting the .nupkg file, I can confirm that the old code is still there and that the new code has not made it into the .nupkg. This seems to support the idea that the problem is with the packaging process and not on the nuget server. How does one refresh the dll files before each nuget pack / nuget push ?

Bit long for a comment, not exactly an answer but here we go:

So top debugging tips for NuGet packages are:

  • Download the package manually. A .nupkg file is just a zip file that can be opened with 7Zip or any other archive tool.

  • Once inside you can inspect both the .nuspec file that has been used to pack the package, and inside the lib folder are the dlls that have been supplied.

  • A decompiler like DotPeek or ILSpy can be used on the dll to see exactly what is going on inside the dll.

Possible causes of your symptoms could include the NuGet server giving a false success, or your application failing to update the package and still refering to the old one.

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