dotnet cli passing -target:Restore to MSBuild instead of -restore
See original GitHub issueAs seen in: https://github.com/xamarin/net6-samples/pull/52
We have a multi-targeted project with:
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
To deploy to an Android device/emulator (and not iOS), you can run:
> dotnet build -t:Run -p:TargetFramework=net6.0-android
With .NET 6.0.100-alpha.1.21064.27, this command fails with:
error MSB4057: The target "Run" does not exist in the project.
The MSBuild arguments the dotnet cli is passing seem odd:
-target:Restore -t:Run
With .NET 6.0.100-alpha.1.20562.2, it used to pass:
-restore -t:Run
In fact, you can workaround the problem by doing:
> dotnet build -t:Run -p:TargetFramework=net6.0-android --no-restore
I tried creating other, simpler projects to reproduce this issue, but a console app with TargetFrameworks=net5.0;net6.0
works fine. I always see -restore
being passed.
I think it is something to with .NET workloads and multi-targeting at the same time?
- Example broken log: broken.zip
- Example working log: works.zip
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (13 by maintainers)
Top Results From Across the Web
dotnet build command - .NET CLI
This command supports the dotnet restore options when passed in the long form (for example, --source ). Short form options, such as -s ......
Read more >.net - Is it possible to set the TargetFramework ...
3. Try dotnet restore -p:TargetFramework=net5.0 · I would say that works! The-p switch appears to be undocumented (learn.microsoft.com/en-us/ ...
Read more >Free style Jenkins build issue for net core application
Using below command MSBUILD. Exe /target:restore /target:build %workspace© Only restore alone happening Target build not executing But build ...
Read more >Setting up a build with NUKE
Let's take a look at NUKE, a cross-platform build automation system with C# DSL. We'll use it to define the build for a...
Read more >Automate your .NET project builds with NUKE a cross- ...
With such an execution plan defined by our targets, we can see that the Clean target is executed before the Restore target and...
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 Free
Top 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
@sfoslund Could you work on fixing this? I tried, but ran into issues where an argument such as
-t:Run
got interpreted as theSlnOrProjectArgument
by the parser, and thus wasn’t handled correctly byRestoringCommand
.Here is the change I made, which added some test coverage and tried to fix
RestoringCommand
: https://github.com/dsplaisted/sdk/commit/ad79b3f866829dba3ca4dd35e6edd3897b7bd460It seems like Sarah was correct here. Fixing one bug (It sounds like
RestoringCommand
wasn’t correctly detecting when it needed to run a separate restore command) exposed another bug. The new bug is that additional targets specified (such asRun
) get passed through to the restore command, when they should be filtered out and only passed to the actual command run after the restore.