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

Using Microsoft.NET.Test.Sdk as GlobalPackageReference breaks the build #5116

Open
astaerk opened this issue Jun 22, 2024 · 1 comment
Open

Comments

@astaerk
Copy link

astaerk commented Jun 22, 2024

Description

When using the package Microsoft.NET.Test.Sdk as GlobalPackageReference in a Directory.Packages.props the build fails with this error:

CS0234	The type or namespace name 'TestPlatform' does not exist in the namespace 'Microsoft.VisualStudio' (are you missing an assembly reference?)	
Project1.Tests	
%UserProfile%\.nuget\packages\microsoft.net.test.sdk\17.10.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.Program.cs	3	

Using it as normal PackageReference in the .csproj works fine.

Steps to reproduce

  • create a new project
  • create a Directory.Packages.props and set ManagePackageVersionsCentrally = true
  • add <GlobalPackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
  • Build

I created a small repo to demonstrate the issue:
https://github.com/proj-arch/Microsoft.NET.Test.Sdk-GlobalPackageReference-BuildError

Expected behavior

the project can be successfully built

Actual behavior

the build breaks with the error

CS0234	The type or namespace name 'TestPlatform' does not exist in the namespace 'Microsoft.VisualStudio' (are you missing an assembly reference?)	
Project1.Tests	
%UserProfile%\.nuget\packages\microsoft.net.test.sdk\17.10.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.Program.cs	3	

Diagnostic logs

Since the build fails, I cannot run the tests with diagnostics.

Environment

  • Windows 10 22H2 (Build 19045.4529)
  • Visual Studio Enterprise 2022 17.10.1
  • vstest.console 17.10.0
  • Microsoft.NET.Test.Sdk package in version 17.10.0
@nohwnd
Copy link
Member

nohwnd commented Jul 1, 2024

It looks like non of the lib files are referenced, adding this test code:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Project1.Tests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
        }
    }
}

Which is a standard test class also tells me that TestClass and TestMethod does not exist. I could not find similar issue reported with GlobalPackageReference, but the nugets look standard, and we produce them from different workflows, so this looks more like the package management problem.

@MichalPavlik have you seen such problem with global package management before?

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

No branches or pull requests

2 participants