Description
Description
We're unable to use the Microsoft.XmlSerializer.Generator package properly because dotnet
is unable to find it properly unless you're using Debug
as the configuration.
We have a large solution that contains some older .NET Framework stuff and some newer .NET Standard/.NET 6+ stuff. We build the solution using msbuild.exe
and we use the configurations Test
(NOT Debug
) and Release
. Additionally, we have a Directory.Build.props/targets
that redirects all build output from bigthing/source/<Project>/[bin|obj]/...
and to a common output location like bigthing/temp/Build/[bin|obj]/<Configuration>/<Project>
.
When building with msbuild
we pass /p:Configuration=Test
(or Release
), but when the Microsoft.XmlSerializer.Generator build targets run, it eventually runs the command dotnet Microsoft.XmlSerializer.Generator <snip extra args...>
(notably, this command does NOT include a configuration). dotnet.exe
attempts to resolve the path to the Microsoft.XmlSerializer.Generator tool by looking in for project.assets.json
, but it ends up using Debug
instead of Test
as the configuration so it fails to find the file and fails to find the tool.
Reproduction Steps
- Create a Directory.Build.props/targets that redirects your build output
- Create a project and reference
Microsoft.XmlSerializer.Generator
- Build the project using a non
Debug
configuration
Expected behavior
dotnet Microsoft.XmlSerializer.Generator
will run successfully.
Actual behavior
dotnet
will be unable to find Microsoft.XmlSerializer.Generator because it can't load the correct project.assets.json
and will fail.
Regression?
No response
Known Workarounds
No response
Configuration
Targeting .NET 6.0
Building using .NET 8.0
The rest of the details here are mostly irellevant.
Other information
Minimal project file that can repro behavior:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.XmlSerializer.Generator" Version="8.0.0" />
</ItemGroup>
</Project>
Also required is a Directory.Build.props/targts
but I don't have that fully isolated yet.