question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET 7.0.100 `dotnet test` cannot parse MSBuild switches from .rsp or command line if .NET CLI language is not `en`

See original GitHub issue

Description

dotnet test command cannot parse parameters from provided .rsp file if .NET CLI language is de or ru but works fine with en on .NET SDK 7.0.100. It leads to an error Unrecognized command or argument ...

This bug is not reproducible on the .NET SDK 6.0.402.

To Reproduce

  1. Create any test project in my case it’s xUnit project targeting net7.0. (please, check test project detail below)
  2. Create any 1.rsp file with at least one switch, for example
-p:abc=123
  1. Set environment variable DOTNET_CLI_UI_LANGUAGE to value de (German). In PowerShell
PS > $env:DOTNET_CLI_UI_LANGUAGE = 'de'
  1. Running the following command
PS > dotnet test .\xUnit.Tests.csproj `@1.rsp

gives

Befehl oder Argument "-p:abc=123" nicht erkannt
Description:
  .NET-Testtreiber

Usage:
  dotnet test [<PROJECT | SOLUTION>] [options] [[--] <additional arguments>...]]

Arguments:
  <PROJECT | SOLUTION>  Das Projekt oder die Projektmappendatei, die verwendet werden soll. Wenn keine Datei angegeben ist,
                        durchsucht der Befehl das aktuelle Verzeichnis nach einer Datei.

Options:
...

Befehl oder Argument "-p:abc=123" nicht erkannt relates to Unrecognized command or argument "-p:abc=123" in English.

  1. Set environment variable DOTNET_CLI_UI_LANGUAGE to value en (English):
PS > $env:DOTNET_CLI_UI_LANGUAGE = 'en'
  1. Running the following command
PS > dotnet test .\xUnit.Tests.csproj `@1.rsp

gives

  Determining projects to restore...
  Restored C:\Users\Maxim.Chechulnikov\sources\small-amount-of-dotnet-tests\mixed\xUnit.Tests\xUnit.Tests.csproj (in 274 ms).
  xUnit.Tests -> C:\Users\Maxim.Chechulnikov\sources\small-amount-of-dotnet-tests\mixed\xUnit.Tests\bin\Debug\net7.0\xUnit.Tests.dl
  l
Test run for C:\Users\Maxim.Chechulnikov\sources\small-amount-of-dotnet-tests\mixed\xUnit.Tests\bin\Debug\net7.0\xUnit.Tests.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:   100, Skipped:     0, Total:   100, Duration: 13 ms - xUnit.Tests.dll (net7.0)

An example of simplest test project

xUnit.Tests.csproj content Content
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>

        <IsPackable>false</IsPackable>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
        <PackageReference Include="xunit" Version="2.4.1" />
        <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="coverlet.collector" Version="3.1.2">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
    </ItemGroup>

</Project>
UnitTests0.cs content Content
namespace xUnit.Tests;

public class UnitTest0
{
    [Fact]
    public void Test0()
    {
        Assert.True(true);
    }

    ...  // I have 100 same tests
}
Usings.cs content Content
global using Xunit;
1.rsp content Content
-p:abc=123

Further technical details

`dotnet --info` output: ``` .NET SDK: Version: 7.0.100 Commit: e12b7af219

Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.100\

Host: Version: 7.0.0 Architecture: x64 Commit: d099f075e4

.NET SDKs installed: 3.1.424 [C:\Program Files\dotnet\sdk] 6.0.401 [C:\Program Files\dotnet\sdk] 6.0.402 [C:\Program Files\dotnet\sdk] 7.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

</details>

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:6
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Evangelinkcommented, Dec 20, 2022

We confirm that this is the same issue as #29543 and that it will be fixed by #29559

1reaction
MarcoRossignolicommented, Dec 21, 2022

I’m going to close as duplicate of https://github.com/dotnet/sdk/issues/29543

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet test error "Unrecognized command or argument" after ...
NET SDK 7.0.100) on the agent TeamCity for build . NET pojects, received a dotnet test run error. Tests fall with error:.
Read more >
dotnet build command - .NET CLI
The dotnet build command builds a project and all of its dependencies.
Read more >
Untitled
NET 7.0.100 dotnet test cannot parse MSBuild switches from .rsp or command line if .NET CLI language is not en #28975 Closed mchechulnikov...
Read more >
Tips & Tricks to improve your .NET Build Setup with MSBuild
MSBuild is the powerful - now open source - build system used in all . NET Builds. It has a language of its...
Read more >
Newest 'dotnet-cli' Questions
I need to create a class library project that uses ML.Net and it needs to be intefrated with an external application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found