Closed WenJunJi01 closed 2 years ago
This issue is in 6.0.3 but works fine in 6.0.202. Upgrading breaks builds. For now, going to force the older 6.0.202 version of dotnet to avoid the issue.
Same issue for us
Same here with --self-contained false
which is meant to work according to the docs: https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli#framework-dependent-executable
This problem also popped-up in our Azure DevOps pipeline. And in combination with /warnaserror is breaking our build...
@marcpopMSFT this is affecting customer builds and appears to be a significant regression in the new 6.0.300 SDK. It has currently been pushed to 6.0.4xx, but it surely needs fixing as a priority.
Brief triage:
_SelfContainedWasSpecified
is not set, and so this condition is being evaluated as true
, and so the warning is fired_SelfContainedWasSpecified
is set here, but only for .NETCoreApp
framework identifiers where HasRuntimeOutput
is set true
I think there may be some corner cases here with libraries (since they don't tend to be targeting .NetCoreApp?) where this condition is never set. We may need a last-chance check for this _SelfContainedWasSpecified
property. It seems like the kind of check that could be more general, not necessarily gated behind the condition it currently is. I'm sure there's some context I'm missing though.
@baronfel what is the official way to specify not self-contained? The docs say it is --self-contained false
, but the warning posted above says it should be --no-self-contained
.
Maybe that is unrelated to the core issue here
It is unrelated to the core issue, but has a simple answer: Due to vagueness in the implementation of the options, you can actually use --self-contained false
instead of --no-self-contained
(and likewise you technically can use --no-self-contained false
to mean --self-contained
). This is not what I recommend - I would suggest using the flag versions (--self-contained
and --no-self-contained
) for clarity, and we can work on the documentation/unifying those representations in the docs and the codebase.
also getting this when upgrading from 6.0.202 to 6.0.300
dotnet publish --configuration Release --output ..\publish-linux-x64 --no-restore --runtime linux-x64 --self-contained /p:SolutionDir=D:\BuildAgent2\work\60950700b4143701\src\ /p:PublishSingleFile=true /p:PublishReadyToRun=false /p:PublishReadyToRunShowWarnings=true /p:PublishTrimmed=false /p:Version=1.1.2.302-ff-3881-update /p:TreatWarningsAsErrors=true /warnaserror /p:IncludeNativeLibrariesForSelfExtract=false -nodeReuse:False
all our exes are built self contained
It seems this was a known regression in 6.0.300 before it was released, what was the rationale of leaving it as-is for the release?
Folks, a workaround in the interim is:
If you're definitely providing the --self-contained
or --no-self-contained
flags, you use the NoWarn
mechanism to silence NETSDK1179.
Adding -p:NoWarn=NETSDK1179
to your command line will do this, as will adding <NoWarn>$(NoWarn);NETSDK1179</NoWarn>
to impacted projects (or to many projects via the Directory.Build.props mechanism).
You can see the before and after here:
@baronfel, if there's a trivial workaround as you suggest, wouldn't it be overall way less effort to issue a hotfix release that contains the workaround until the issue is properly fixed; as opposed to expecting a multitude of customers to individually and manually apply the workaround, and put them in a precarious position where it's easy to forget about it and permanently disable this warning as an unintended side effect?
@nagya we're working on a fix quickly in the linked PR and will be taking it to servicing.
note that the -p:NoWarn=NETSDK1179
doesn't always work - in some of my projects its started failing due to something that was suppressed, which no longer is when this parameter is added
We got approval to fix this in 6.0.301 servicing. That is currently planned for release in June.
Great news. However @marcpopMSFT, trying to understand how this issue (which affects many people) was known before release (back on March 8th), but still made it out. Realizing it would affect automated builds everywhere...
@waynebrantley we didn't catch during triage that this was different than https://github.com/dotnet/sdk/pull/23999 which we thought we'd already fixed so assumed this issue as much narrower than it was. We'll be reviewing our triage process but folks can also ping us directly to get attention on issues we may be missing.
@marcpopMSFT Hey, things get missed - it happens! As far as the triage process, I was not referring to the ticket you referenced - I was referencing this ticket. Anyway, glad you guys are on it. Thank you very much!!
Verified on .NET SDK 6.0.301and it is fixed and not repro, so close it.
It still reproduces for 6.0.403 Error log: /opt/hostedtoolcache/dotnet/sdk/6.0.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(1114,5): warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used. [/home/vsts/work/1/s/src/KMS/KMS.csproj]
Are you using 6.0.403 with 17.4 by any chance?
Please re-open this. I also use .NET SDK 6.0.403 and MSBUILD 17.4.0
This seem to be not fixed and it also happens when calling dotnet clean
.
Thing is you can't add the --self-contained
argument to the clean
command. As a workaround, ignoring the warning with -p:NoWarn=NETSDK1179
does work, but this really should be fixed.
Per my question above, we have a known issue where we'll still show this warning in the specific combination of 17.4 and 6.0.400. At the moment, we do not have plans to address this though I'm open to continued feedback.
I would like to understand why customers are choosing to use 6.0.400 with 17.4 as .400 includes tooling from 17.3 and is tested with 17.3. While you can overwrite the values through global.json, we don't recommend doing that with Visual Studio/msbuild if you can help it.
Ah, okay. In my current scenario we have still netcoreapp3.1, net6.0 and net7.0 projects together. Migrating them takes time (they grew for a few years ;) ).
So I use the dotnet command with the --framework
switch to address them individually.
But in this case it's the clean command that produces the warning and for cleaning I can work around that with the NoWarn
property on the command. For building and publishing I can provide the --self-contained
switch, so that is fine too.
Could you try using the 7.0.100 SDK to build all three projects? It should be able to build them and would avoid the issue I mentioned above where 17.4 + 6.0.400 has an issue.
Environment: .NET SDK 6.0.300-preview.22154.4 (runtime-6.0.2)
Repro steps:
Expected Result: Warning NETSDK1179 should not display.
Actual Result: warning NETSDK1179 still shows after adding '--self-contained' or '--no-self-contained'.
Dotnet info: .NET SDK (reflecting any global.json): Version: 6.0.300-preview.22151.9 Commit: c5b0a4598d
Runtime Environment: OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.300-preview.22151.9\
Host (useful for support): Version: 6.0.2 Commit: 839cdfb0ec
.NET SDKs installed: 6.0.300-preview.22151.9 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download