avalonia-dotnet-templates icon indicating copy to clipboard operation
avalonia-dotnet-templates copied to clipboard

Conditional `Avalonia.Diagnostics`

Open PetSerAl opened this issue 6 months ago • 0 comments

Is your feature request related to a problem? Please describe.

Avalonia template include conditional package Avalonia.Diagnostics with Condition attribute directly on PackageReference element. https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/43c5d489827688e412c98722ba1963039c66e9a5/templates/csharp/app/AvaloniaAppTemplate.csproj#L18-L19 Such approach is not friendly with lock file. For example:

dotnet restore --use-lock-file -property:Configuration=Debug
dotnet restore --use-lock-file --locked-mode -property:Configuration=Release

Second command will fail with NU1004 error.

Describe the solution you'd like

Move conditional attribute to metadata IncludeAssets and PrivateAssets:

<PackageReference Include="Avalonia.Diagnostics" Version="AvaloniaVersionTemplateParameter">
  <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
  <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>

That exclude assembly from Release build output, but allows restore with --locked-mode.

Describe alternatives you've considered

No response

Additional context

No response

PetSerAl avatar Aug 25 '24 09:08 PetSerAl