dotnet test does no longer accept a project path after updating to NET 7.0.101
See original GitHub issueDescribe the bug
After updating NET 7.0.100 to NET 7.0.101 dotnet test
does no longer accept a project path as an argument.
To Reproduce
Sample test project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
using Xunit;
namespace ClassLibrary1
{
public class Class1
{
[Fact]
public void Test()
{
}
}
}
With NET 7.0.101 this does not work
C:\>dotnet --version
7.0.101
C:\>dotnet test C:\Users\Administrator\Desktop\ClassLibrary1.csproj
Befehl oder Argument "C:\Users\Administrator\Desktop\ClassLibrary1.csproj" nicht erkannt
With NET 7.0.100 this worked
C:\>dotnet --version
7.0.100
C:\>dotnet test C:\Users\Administrator\Desktop\ClassLibrary1.csproj
Determining projects to restore...
All projects are up-to-date for restore.
ClassLibrary1 -> C:\Users\Administrator\Desktop\bin\Debug\net7.0\ClassLibrary1.dll
Test run for C:\Users\Administrator\Desktop\bin\Debug\net7.0\ClassLibrary1.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - ClassLibrary1.dll (net7.0)
This also affects the built in dotnet command in Azure Dev Ops.
Workarounds
-
Set the environment variable
DOTNET_CLI_UI_LANGUAGE=en-US
. -
Running
donet test
directly in the project directory does work:
C:\Users\Administrator\Desktop>dotnet test
Wiederherzustellende Projekte werden ermittelt...
Alle Projekte sind für die Wiederherstellung auf dem neuesten Stand.
ClassLibrary1 -> C:\Users\Administrator\Desktop\bin\Debug\net7.0\ClassLibrary1.dll
Testlauf für "C:\Users\Administrator\Desktop\bin\Debug\net7.0\ClassLibrary1.dll" (.NETCoreApp,Version=v7.0)
Microsoft (R) Testausführungs-Befehlszeilentool Version 17.4.0 (x64)
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
Die Testausführung wird gestartet, bitte warten...
Insgesamt 1 Testdateien stimmten mit dem angegebenen Muster überein.
Bestanden! : Fehler: 0, erfolgreich: 1, übersprungen: 0, gesamt: 1, Dauer: < 1 ms - ClassLibrary1.dll (net7.0)
- Running
donet test
referencing a DLL or exe does work:
C:\Users\Administrator\Desktop>dotnet test C:\Users\Administrator\Desktop\bin\Debug\net7.0\ClassLibrary1.dll
Wiederherzustellende Projekte werden ermittelt...
Alle Projekte sind für die Wiederherstellung auf dem neuesten Stand.
ClassLibrary1 -> C:\Users\Administrator\Desktop\bin\Debug\net7.0\ClassLibrary1.dll
Testlauf für "C:\Users\Administrator\Desktop\bin\Debug\net7.0\ClassLibrary1.dll" (.NETCoreApp,Version=v7.0)
Microsoft (R) Testausführungs-Befehlszeilentool Version 17.4.0 (x64)
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
Die Testausführung wird gestartet, bitte warten...
Insgesamt 1 Testdateien stimmten mit dem angegebenen Muster überein.
Bestanden! : Fehler: 0, erfolgreich: 1, übersprungen: 0, gesamt: 1, Dauer: < 1 ms - ClassLibrary1.dll (net7.0)
Further technical details
C:\>dotnet --info
.NET SDK:
Version: 7.0.101
Commit: bb24aafa11
Laufzeitumgebung:
OS Name: Windows
OS Version: 10.0.20348
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.101\
Host:
Version: 7.0.1
Architecture: x64
Commit: 97203d38ba
.NET SDKs installed:
7.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Issue Analytics
- State:
- Created 9 months ago
- Reactions:14
- Comments:22 (11 by maintainers)
Top Results From Across the Web
Started to get "This project is targeting a version of .NET ...
I just checked with dotnet --info, the 3.1 runtime and SDK are already installed. Even after allowing VS to install the version it...
Read more >dotnet test command - .NET CLI
The dotnet test command builds the solution and runs a test host application for each test project in the solution.
Read more >Microsoft Visual Studio 2019: The project file cannot be ...
I found that the path C:\Program Files\dotnet was already in my path but it was ordered below the C:\Program Files (x86)\dotnet entry. By...
Read more >Visual Studio 2019 unable to locate .Net Core SDK
Find the path to dotnet.exe manually (usually C:\Program Files\dotnet ) and add it to PATH. Check in Control Panel whether there is a...
Read more >Dotnet test error "Unrecognized command or argument" after ...
After updated the `VS Build Tool` to version 17.4 (.NET SDK 7.0.100) on the agent TeamCity for build . NET pojects, received a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Setting the environment variable
DOTNET_CLI_UI_LANGUAGE=en-US
does also fix the issue.Probably introduced with this pr: https://github.com/dotnet/sdk/pull/27961
This is blocking all of my CI runs