microsoft / vstest

Visual Studio Test Platform is the runner and engine that powers test explorer and vstest.console.
MIT License
870 stars 316 forks source link

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

Open astaerk opened 1 week ago

astaerk commented 1 week ago

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

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