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.

dotnet publish -p:PublishSingleFile fails with Unhandled exception on .net 7 it works on .net 6

See original GitHub issue

Describe the bug

When running dotnet publish with a msbuild property without an equal sign ‘=’ like this dotnet publish -c Release -p:PublishSingleFile the command fails hard with an System.IndexOutOfRangeException: Index was outside the bounds of the array. The same thing can be observed by running dotnet publish -c Release -p:WhatEver

The same command works without the unhandled exception in .net 6. (v6.0.406) - works as in, it does not fail hard 😄

To Reproduce

With .net 7 run the following command

dotnet publish -c Release -p:PublishSingleFile

Exceptions (if any)

Unhandled exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Unhandled exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Microsoft.DotNet.Cli.ReleasePropertyProjectLocator.GetGlobalPropertiesFromUserArgs(ParseResult parseResult)
   at Microsoft.DotNet.Cli.ReleasePropertyProjectLocator.GetCustomDefaultConfigurationValueIfSpecified(ParseResult parseResult, String defaultedConfigurationProperty, IEnumerable`1 slnOrProjectArgs, Option`1 configOption)+MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at Microsoft.DotNet.Tools.Publish.PublishCommand.FromParseResult(ParseResult parseResult, String msbuildPath)
   at Microsoft.DotNet.Tools.Publish.PublishCommand.Run(ParseResult parseResult)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Cli.Parser.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__17_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass7_0.<<UseExceptionHandler>b__0>d.MoveNext()

Further technical details

.NET SDK: Version: 7.0.200 Commit: 534117727b

Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64

Host: Version: 7.0.3 Architecture: x64 Commit: 0a2bda10e8

.NET SDKs installed: 6.0.406 [C:\Program Files\dotnet\sdk] 7.0.102 [C:\Program Files\dotnet\sdk] 7.0.103 [C:\Program Files\dotnet\sdk] 7.0.200 [C:\Program Files\dotnet\sdk]

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
niklasfpcommented, Feb 27, 2023
1reaction
nagilsoncommented, Feb 27, 2023

Closed as this is going into servicing for 7.0.2xx, it will likely release with this fix in April.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publish NET 6 app in pipeline fails with "type not found ...
Based on an example I found I call dotnet build via script and this PASSES. The MS docs state that all parameters in...
Read more >
NET 6 breaking change: Exception handling in hosting - .NET
The best default behavior is to stop the host, because unhandled exceptions shouldn't be ignored. They indicate a problem that needs attention.
Read more >
How do I fix the error: "Unhandled exception. System.IO. ...
The error message indicates you are missing the dotnet-aspnet-codegenerator-design, Version=7.0.6.0 package. You either have to install the ...
Read more >
ANCM Out-Of-Process Startup Failure after I downgrade to ...
So, after changing net7.0 in your project file to net6.0 you did run dotnet publish again to publish the artifacts, didn't you?
Read more >
Unable to compile .net 6.0 projects in VS 2022
I am unable to compile .net 6.0 projects in VS 2022 (version 17.4.3). I see error message that - MSB3971 The reference assemblies...
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