sdk icon indicating copy to clipboard operation
sdk copied to clipboard

MSBuild error for dotnet build with --self-contained

Open ndavidsmk opened this issue 5 years ago • 1 comments

Describe the bug

The --self-contained switch cannot be passed to the dotnet build command in SDK versions 5.0.400 and 5.0.401

PS C:\1ADO\DH-EPS-EHSE-EPICEdgeScanner\src> dotnet --version
5.0.401
PS C:\1ADO\DH-EPS-EHSE-EPICEdgeScanner\src> dotnet build EHS.sln --self-contained false
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1001: Unknown switch.
Switch: --self-contained

For switch syntax, type "MSBuild -help"
PS C:\1ADO\DH-EPS-EHSE-EPICEdgeScanner\src>

To Reproduce

Using SDK 5.0.4xx, run dotnet build SolutionName.sln --self-contained false

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.401
 Commit:    4bef5f3dbf

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.401\

Host (useful for support):
  Version: 5.0.10
  Commit:  e1825b4928

.NET SDKs installed:
  5.0.401 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version Visual Studio 2019 (16.11.3) with .NET SDK 5.0.401

ndavidsmk avatar Sep 14 '21 20:09 ndavidsmk

This is expected, the --self-contained switch wasn't added until .NET 6: https://github.com/dotnet/sdk/commit/14c1b06149cc0f30829448b1bf3918d2692cec9a#diff-358d22e73492cba5ade6f79b3ce1c626be9394887f6d91b8227c6a368dccaa56. To specify self contained in .NET 5, you can use -property:SelfContained=true

sfoslund avatar Sep 20 '21 18:09 sfoslund