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.

Error parsing dotnet publish parameters when using ReadyToRun

See original GitHub issue

Version: 3.0.100-preview5-011507 Commit: fddc070d00

When running dotnet publish using both -p:ReadyToRun and --self-contained the message is misleading:

$ dotnet publish -c Release -r linux-arm --self-contained -p:ReadyToRun=true -o scd
Microsoft (R) Build Engine version 16.1.65-preview+gc86abee47b for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/opt/dotnet/sdk/3.0.100-preview5-011507/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.TargetingPackResolution.targets(85,33): error MSB4030: "-p:ReadyToRun=true" is an invalid value for the "SelfContained" parameter of the "ResolveFrameworkReferences" task.
The "SelfContained" parameter is of type "System.Boolean". [/home/pi/test3/test3.csproj]

If instead, I specify =true the command succeed:

 $ dotnet publish -c Release -r linux-arm --self-contained=true -p:ReadyToRun=true -o scd
Microsoft (R) Build Engine version 16.1.65-preview+gc86abee47b for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 372.72 ms for /home/pi/test3/test3.csproj.
/opt/dotnet/sdk/3.0.100-preview5-011507/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/home/pi/test3/test3.csproj]
  test3 -> /home/pi/test3/bin/Release/netcoreapp3.0/linux-arm/test3.dll
  test3 -> /home/pi/test3/bin/Release/netcoreapp3.0/linux-arm/test3.Views.dll
  test3 -> /home/pi/test3/scd/

It looks like -p:ReadyToRun already forces --self-contained=true but I would like the command output to clearly states whether the produced output is self-contained or not.

By the way, the parameter --self-contained can be used alone (without =true) and it has been possible even in .NET Core 2.x. The following command is valid and succeeds:

dotnet publish -c Release -r linux-arm --self-contained -o abc

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
livarcocccommented, May 8, 2019

The problem here is how the parser works. The issue in particular is not about ReadyToRun, but also that you are passing a -p value after self-contained. Because that is not a special value to the parser, like -o, that we intercept and translate, the parser is seeing some value after --self-contained and assumes that it is the value being passed to self-contained.

In this case, I would recommend passing a value to self-contained <true|false> as a way around this. Meanwhile, @peterhuene anything we could do in the parser to improve this?

1reaction
AntonLapounovcommented, Jun 17, 2022

I have tried your publish command on .NET 6 and --self-contained -p:ReadyToRun=true just works now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET SDK error list - .NET CLI
A complete list of NETSDKxxxx errors, with links to more info where more info is available.
Read more >
Publish ReadyToRun with --no-restore requires changes
Learn about the breaking change in .NET 6 where publishing a project with ReadyToRun requires changes to the way the project is restored....
Read more >
ReadyToRun deployment overview - .NET
To compile your project as ReadyToRun, the application must be published with the PublishReadyToRun property set to true . There are two ways...
Read more >
Breaking changes in .NET 6
Navigate to the breaking changes in .NET 6. ... NET Core or Windows Forms. ... Publish ReadyToRun with --no-restore requires changes ...
Read more >
JsonConvert.DeserializeObjects does not work with trim ...
The method JsonConvert.DeserializeObjects works when "Trim unused code" publish setting is off. When I turn this setting on I get: Newtonsoft.
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