Executing test project with dotnet run -p
fails unless --framework
option is passed to dotnet run
#239
Labels
dotnet run -p
fails unless --framework
option is passed to dotnet run
#239
Describe the bug
If I create a new project from the MiniScaffold template, then try to run the Expecto unit tests with
dotnet run -p tests/Foo.Tests/Foo.Tests.fsproj
, I get the error "Unable to run your project. Your project targets multiple frameworks. Specify which framework to run using '--framework'."Editing Foo.Tests.fsproj and changing
<TargetFrameworks>net5.0</TargetFrameworks>
to<TargetFramework>net5.0</TargetFramework>
fixes the issue, suggesting that dotnet/sdk#8676 is the root cause.To Reproduce
Steps to reproduce the behavior:
dotnet new mini-scaffold -n Foo -o Foo ; cd Foo
./build.sh
once to restore packages (it fails on the F# Analyzers step, but that's an unrelated issue)dotnet run -p tests/Foo.Tests/Foo.Tests.fsproj
. Fails.dotnet run -p tests/Foo.Tests/Foo.Tests.fsproj --framework net5.0
. Succeeds.Expected behavior
dotnet run -p tests/Foo.Tests/Foo.Tests.fsproj
should succeed without specifying the--framework
option, since there's only one targeted framework in the project.Desktop (please complete the following information):
Additional context
I initially noticed this when I tried to run the tests using Ionide's "run" tool on the test project. That is, this one:
The DotnetTest step in
build.fsx
succeeded even with TargetFrameworks in the .fsproj file, so I wouldn't have noticed this issue if the F# Analyzers step hadn't failed. But when F# Analyzers failed, instead of commenting out the==> "FSharpAnalyzers"
step, I loaded the project into VS Code and tried running tests with Ionide's "run" button, which callsdotnet run -p (project file)
. That's how I discovered this issue.So it's a relatively minor issue, and it's easily fixed by changing TargetFrameworks to TargetFramework in all the .fsproj files. But then it may not be immediately clear to .NET newbies how to compile against multiple frameworks if they want to. So this might turn out to be a "won't fix" because the drawbacks of making that change might outweigh the benefits.
The text was updated successfully, but these errors were encountered: