Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuget Package Updates Not Working #4188

Closed
chocvanstraw opened this issue Nov 28, 2024 · 8 comments
Closed

Nuget Package Updates Not Working #4188

chocvanstraw opened this issue Nov 28, 2024 · 8 comments

Comments

@chocvanstraw
Copy link

I just created an MSTest project targeting .net 9. When I go to the Nuget package manager it says I have 4 updates for the following packages:

Microsoft.NET.Test.Sdk 17.11.1 -> 17.12.0
MSTest.Analyzers 3.6.1 -> 3.6.3
MSTest.TestAdapter 3.6.1 -> 3.6.3
MSTest.TestFramework 3.6.1 -> 3.6.3

If I update all of the packages they seem to update fine (the versions change in the project that was updated). However, if I rebuild the solution, the 4 packages listed above all revert back to the previous version. If I go to the nuget package manager, it shows 4 updates again.

Before update:

Image

After update:

Image

After building the solution:

Image

@Youssef1313
Copy link
Member

Youssef1313 commented Nov 28, 2024

@chocvanstraw Thanks for reporting this. Are you using MSTest.Sdk?

If you're using MSTest.Sdk, please have a look at the limitations documented in https://github.com/dotnet/docs/blob/087483735e3284d6e4f7d078b7fe66ae57218b8c/docs/core/testing/unit-testing-mstest-sdk.md#known-limitations (the known limitations section will isn't yet published to https://learn.microsoft.com/dotnet/core/testing/unit-testing-mstest-sdk, but hopefully it will be soon).

NuGet issue: NuGet/Home#13127

@chocvanstraw
Copy link
Author

Sorry for the delayed response. The Packages I am referencing in the test project are as follows:

Microsoft.NET.Test.SDK
MSTest.Analyzers
MSTest.TestAdapter
MSTest.TestFramework

I also noticed that after updating the nugets to the latest version and building the solution the versions in the IDE solution explorer show the old version (as mentioned in my original post). However, if I look at the csproj file for the test project they show the new versions:

Image

I also noticed that when creating a new test project there are several options that now have to be selected, which is a new experience for these types of projects. It isn't really clear what the implication of selecting each option is. Here is an example:

Image

Is the Use MSTest.Sdk checkbox causing the problem?

@chocvanstraw
Copy link
Author

chocvanstraw commented Dec 2, 2024

I created a new project with the following settings (specifically unchecking the Use MSTest.SDK option):

Image

This included different nuget packages in the project:

Image

These seem to play nicely with the nuget package manager. When I manage nugets, I was able to update the listed packages to the latest version and they didn't change after re-building the solution and the versioning is consistent in solution explorer and the csproj file. It might be worthwhile to have some explanation of what all these various settings accomplish.

@Evangelink
Copy link
Member

@chocvanstraw Is the line containing <Project Sdk=" uses MSTest.Sdk or Microsoft.NET.Sdk? If it uses MSTest.Sdk then you are using our custom build SDK which is currently having some limitations as described by @Youssef1313.. If it uses Microsoft.NET.Sdk, we would need a reproducer because that's a bug.

@chocvanstraw
Copy link
Author

chocvanstraw commented Dec 2, 2024

In the original project I see the following: <Project Sdk="MSTest.Sdk/3.6.1">

In the new project, where I unchecked Use MSTest.SDK I see the following: <Project Sdk="Microsoft.NET.Sdk">

@Youssef1313
Copy link
Member

@chocvanstraw So, the update functionality works correctly with Microsoft.NET.Sdk but not for MSTest.Sdk right? In that case, that's unfortunately the known limitation I referred to :(

@chocvanstraw
Copy link
Author

It appears so. So, which is the preferred library? Microsoft.NET.Sdk or MSTest.Sdk? It seems that Microsoft.NET.Sdk is installed regardless. And what is the guidance for new projects when it comes to selecting the Use MSTest.SDK checkbox?

@Evangelink
Copy link
Member

So, which is the preferred library? Microsoft.NET.Sdk or MSTest.Sdk?

It depends mainly on your feeling. We tend to recommend MSTest.Sdk as it reduces a lot of boilerplate in project configurations but we are aware that the limited integration for updates can be considered as blocker.

It seems that Microsoft.NET.Sdk is installed regardless.

If the Use MSTest Sdk checkbox is used, your project will use this SDK otherwise (when unchecked) it uses the regular .NET SDK (Microsoft.NET.Sdk).

what is the guidance for new projects when it comes to selecting the Use MSTest.SDK checkbox?

Cf question 1. We do think that provides a better experience but that's up-to-you.

In case you have missed them, here is our blog post announcing the SDK feature https://devblogs.microsoft.com/dotnet/introducing-mstest-sdk/ and here is the official doc that explains the custom Sdk and its features https://learn.microsoft.com/dotnet/core/testing/unit-testing-mstest-sdk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants