dotnet-releaser: Windows: MSB4016 error on build
Hi, I’m following the instructions from the README but I’m running into an MSBuild failure when I try to run dotnet-releaser build
. I’ve put together a minimal repro here.
Steps to Reproduce
Create a console app:
dotnet new console
Initialize the dotnet-releaser
config:
dotnet-releaser new --project ReleaserRepro.csproj
Run dotnet-releaser build
, observe the “Failing to run dotnet msbuild” error:
❯ dotnet-releaser build --force dotnet-releaser.toml
info: dotnet-releaser[0]
Loading configuration from C:\Users\reill\source\releaser-repro\dotnet-releaser.toml
fail: dotnet-releaser[1]
The changelog.path was not setup
info: dotnet-releaser[2]
Adding default profile for platform [win-x64] with [Zip] package
Adding default profile for platform [win-arm] with [Zip] package
Adding default profile for platform [win-arm64] with [Zip] package
Adding default profile for platform [linux-x64] with [Deb, Tar] packages
Adding default profile for platform [linux-arm] with [Deb, Tar] packages
Adding default profile for platform [linux-arm64] with [Deb, Tar] packages
Adding default profile for platform [rhel-x64] with [Rpm, Tar] packages
Adding default profile for platform [osx-x64] with [Tar] package
Adding default profile for platform [osx-arm64] with [Tar] package
fail: dotnet-releaser[3]
Failing to run dotnet msbuild -p:Configuration=Release -p:CustomAfterMicrosoftCommonTargets="C:\Users\reill\.dotnet\tools\.store\dotnet-releaser\0.1.0\dotnet-releaser\0.1.0\tools\net6.0\any\dotnet-releaser.targets" -nologo -logger:BinaryLogger,"C:\Users\reill\.dotnet\tools\.store\dotnet-releaser\0.1.0\dotnet-releaser\0.1.0\tools\net6.0\any\dotnet-releaser-binary-logger.dll";"C:\Users\reill\AppData\Local\Temp\tmpC534.tmp.binlog" -t:DotNetReleaserGetPackageInfo C:\Users\reill\source\releaser-repro\ReleaserRepro.csproj. Reason: MSBUILD : error MSB4016: The build stopped unexpectedly because the "ReusableLogger" logger failed unexpectedly during initialization. Object reference not set to an instance of an object.
Version Info
dotnet-releaser
v0.1.0, Windows 11, and the .NET 6 SDK that comes installed with VS 2022 17.1.0 Preview 4:
.NET SDK (reflecting any global.json):
Version: 6.0.200-preview.22055.15
Commit: a3c3a2bf3b
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.200-preview.22055.15\
Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc
P.S. Thank you so much for making dotnet-releaser
- it fills a really important gap in the .NET OSS ecosystem!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 31 (24 by maintainers)
Thanks, I’ve filed https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/558 and will investigate it there.
Ouch.
And fantastic job @rgwood, this is really helpful.
I guess we haven’t seen this because not a lot of people use the BinaryLogger copy from StructuredLogger.dll (almost everyone uses the original from MSBuild). Yeah, let’s think about what’s the right thing to do is here.
I filed https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/556 so feel free to watch that for further development. For now the cheapest tactical fix is to probe for both field names and use the one that’s not null.
Disabling Just My Code worked!
It doesn’t, and I can’t repro on my machine, but I’d certainly be the right person to investigate this and it’s likely my fault somehow 😃 Do you have a full call stack?
You can use the Child Process Attach VS extension: https://marketplace.visualstudio.com/items?itemName=vsdbgplat.MicrosoftChildProcessDebuggingPowerTool
Then debug dotnet-releaser.exe with Mixed mode (Managed + Native) in VS, enable Child Process Attach, enable first-chance exceptions (Debug -> Exceptions -> All .NET exceptions), then debug and it will get you a call stack of the exception. Paste that callstack here (and ideally the source location where it happens) and we can investigate further.
It looks like a bug in MSBuild currently (nothing a user is doing should be causing a NullRef in MSBuild), but we need to understand what is going on first (and whether it’s MSBuild or the SDK).
Excellent repro steps @rgwood, I appreciate good bugs when I see them!
Great, thanks! I have removed using it from
0.1.8+
Great. The changelog issue should be fixed in
0.1.3+
I think the error is
The changelog.path was not setup
in the log above, so indotnet-releaser
. Gonna push a fix because it’s supposed to skip it when it is not set.And to answer your question about why Reflection is necessary - these fields shouldn’t be exposed to the general public, but I need access for obscure reasons (binary serialization). Maybe it’s worth thinking about opening them up, but in MSBuild land, once we open anything up, we can never change it, so we’ve been cautious about making more foundational stuff public. The perf improvement two months ago that broke my reflection wouldn’t have been possible had we had those fields public.
Thanks for reproducing the bug @rgwood and investigating it!
There’s a way to debug an .exe in VS if you don’t have the sources. In VS, open the .exe as a Project (File -> Open Project), it will open as a pseudo-project, you can right-click the “project” in Solution Explorer, open Properties, fill out the arguments, working directory, environment variables, debug engine (has to be Mixed for Child Process Attach to work), then just F5.
This trick is generally useful if you don’t have the source.
Or you can attach to an already running process, but it’s less convenient and since JIT optimizes all modules on load by default, you won’t see any variables in the locals window.