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

Passing MSBuild properties to 'dotnet test' is not working in .NET 7 RC2 #28511

Closed
philasmar opened this issue Oct 12, 2022 · 4 comments
Closed
Labels
Area-DotNet Test untriaged Request triage from a team member

Comments

@philasmar
Copy link

Describe the bug

Passing MSBuild properties to 'dotnet test' is not working in .NET 7 RC2.
If you try to run a command like dotnet test <csproj path> /p:Framework=net7.0, the Framework property does not get propagated.
This works fine with dotnet build but it stopped working with dotnet test in .NET 7.

To Reproduce

If you have a csproj such as:

<Project Sdk="Microsoft.NET.Sdk">

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

  <PropertyGroup Condition=" '$(Framework)'=='net6.0' ">
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Framework)'=='net7.0' ">
    <TargetFramework>net7.0</TargetFramework>
  </PropertyGroup>

</Project>

Try to run dotnet test <csproj path> -v n /p:Framework=net7.0 and this should fail with the error:

error NETSDK1013: The TargetFramework value '' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly.

I have .NET 7 RC2 installed. I tried to add a global.json to force .NET 6 to be used and the command worked as expected. The issue is only observed in .NET 7.

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
.NET SDK:
 Version:   7.0.100-rc.2.22477.23
 Commit:    0a5360315a

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

Host:
  Version:      7.0.0-rc.2.22472.3
  Architecture: x64
  Commit:       550605cc93

.NET SDKs installed:
  6.0.400 [C:\Program Files\dotnet\sdk]
  7.0.100-rc.2.22477.23 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.8 [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-rc.2.22476.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.28 [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.8 [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.WindowsDesktop.App 3.1.28 [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.8 [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-rc.2.22472.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

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

Download .NET:
  https://aka.ms/dotnet/download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    I am running Visual Studio 2022 but the issue is observed on the command line.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-DotNet Test untriaged Request triage from a team member labels Oct 12, 2022
@baronfel
Copy link
Member

I believe this is the same report as microsoft/vstest#4014, which we have a PR outstanding on (that @nohwnd and I need to get across the finish line).

@philasmar
Copy link
Author

Is this going to be finalized in time for .NET 7 GA?

@nagilson
Copy link
Member

nagilson commented Nov 3, 2022

@philasmar Sadly it's too late for the initial GA release, but I think this will go in for servicing.

@nagilson
Copy link
Member

nagilson commented Nov 4, 2022

With that being said, @baronfel has been working hard to get it fixed. Closing this as a duplicate, the rest is tracked in the linked issue. Thanks for reporting it, it's important this is fixed!

@nagilson nagilson closed this as completed Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-DotNet Test untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants