sdk: Self-contained publish regression in .NET 9 RC1
Describe the bug
A WPF project using DevExpress components, WCF and a handful of third-party NuGet packages can be published self-contained correctly when targeting net8.0-windows. All relevant .dll files are present in the published output, and the application runs as expected.
When the project is re-targeted to net9.0-windows, the self-contained publish output no longer includes certain WPF assemblies (e.g. PresentationCore.dll or PresentationFramework*.dll) The published application now crashes at startup because it cannot find these WPF assemblies.
The steps provided below are a minimal reproducible example extracted from the actual application.
To Reproduce
Note: an active subscription for access to the DevExpress NuGet package source https://nuget.devexpress.com/${YOUR_SUBSCRIPTION_KEY_HERE}/api/v3/index.json will be required.
Download the script at https://gist.github.com/nil4/9f6c787205340b8b45a7cfe504ba7400 and on line 8, replace the placeholder value with a DevExpress subscription key.
Running the script (pwsh repro.ps1) will:
- create a new WPF project
- add the relevant DevExpress, Microsoft and third-party NuGet package references required to observe the issue
- publish the project and verify that the output includes the expected WPF assemblies (e.g.
Presentation*.dll)
The script creates two projects, first targeting net8.0 and then net9.0. The publish output for net8.0 consistently includes the WPF assemblies.
The publish output for net9.0, once the final NuGet package reference is added, no longer includes the expected WPF assemblies.
This appears to be a regression, and an unexpected breaking change in .NET 9.0 RC1.
net8.0 publishing correctly
Testing net8.0 repro under C:\repro\repro_8
Creating new net8.0 WPF project in C:\repro\repro_8
Disabling <ImplicitUsings> in C:\repro\repro_8\repro_8.csproj
Adding package DevExpress.Mvvm 24.1.5 in C:\repro\repro_8
Adding package DevExpress.Win.Navigation 24.1.5 in C:\repro\repro_8
Adding package DevExpress.Win.Grid 24.1.5 in C:\repro\repro_8
Adding package System.ServiceModel.Http 8.0.0 in C:\repro\repro_8
Adding package System.ServiceModel.Primitives 8.0.0 in C:\repro\repro_8
Adding package System.Drawing.Common 8.0.8 in C:\repro\repro_8
Adding package System.Formats.Asn1 8.0.1 in C:\repro\repro_8
Publishing C:\repro\repro_8 to C:\repro\repro_8\bin\publish
✅ Found 15 files matching C:\repro\repro_8\bin\publish\Presentation*.dll
Adding package Tulpep.ActiveDirectoryObjectPicker 3.0.11 in C:\repro\repro_8
Publishing C:\repro\repro_8 to C:\repro\repro_8\bin\publish
✅ Found 15 files matching C:\repro\repro_8\bin\publish\Presentation*.dll
net9.0 missing expected output
Testing net9.0 repro under C:\repro\repro_9
Creating new net9.0 WPF project in C:\repro\repro_9
Disabling <ImplicitUsings> in C:\repro\repro_9\repro_9.csproj
Adding package DevExpress.Mvvm 24.1.5 in C:\repro\repro_9
Adding package DevExpress.Win.Navigation 24.1.5 in C:\repro\repro_9
Adding package DevExpress.Win.Grid 24.1.5 in C:\repro\repro_9
Adding package System.ServiceModel.Http 8.0.0 in C:\repro\repro_9
Adding package System.ServiceModel.Primitives 8.0.0 in C:\repro\repro_9
Adding package System.Drawing.Common 9.0.0-rc.1.24451.1 in C:\repro\repro_9
Adding package System.Formats.Asn1 9.0.0-rc.1.24431.7 in C:\repro\repro_9
Publishing C:\repro\repro_9 to C:\repro\repro_9\bin\publish
✅ Found 16 files matching C:\repro\repro_9\bin\publish\Presentation*.dll
Adding package Tulpep.ActiveDirectoryObjectPicker 3.0.11 in C:\repro\repro_9
Publishing C:\repro\repro_9 to C:\repro\repro_9\bin\publish
⛔ Found NO files matching C:\repro\repro_9\bin\publish\Presentation*.dll
Further technical details
<kbd>dotnet --info</kbd>
.NET SDK:
Version: 9.0.100-rc.1.24452.12
Commit: 81a714c6d3
Workload version: 9.0.100-manifests.a7bf2b8f
MSBuild version: 17.12.0-preview-24422-09+d17ec720d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-arm64
Base Path: C:\Program Files\dotnet\sdk\9.0.100-rc.1.24452.12\
Host:
Version: 9.0.0-rc.1.24431.7
Architecture: arm64
Commit: static
.NET SDKs installed:
8.0.400 [C:\Program Files\dotnet\sdk]
9.0.100-rc.1.24452.12 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x64 [C:\Program Files\dotnet\x64]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation]
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
The repro script for reference:
<kbd>repro.ps1<kbd>
#Requires -PSEdition Core -Version 7.4
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$PSStyle.OutputRendering = 'ANSI'
# Configure a DevExpress subscription/API key here
$DX_SUBSCRIPTION = '!!!! Add-DevExpress-Subscription-Key-Here !!!!'
$DX_NUGET_API = "https://nuget.devexpress.com/${DX_SUBSCRIPTION}/api/v3/index.json"
$NUGET_API = 'https://api.nuget.org/v3/index.json'
function add_package([string]$package, [string]$version, [string]$sourceUrl) {
Write-Host "Adding package ${package} ${version} in ${PWD}" -ForegroundColor Cyan
& dotnet.exe add package $package --version $version --no-restore --source $sourceUrl
}
function remove_dir([string]$dir) {
if (Test-Path $dir -PathType Container) {
Remove-Item $dir -Force -Recurse
}
}
function publish_and_test([string]$publishDir) {
Write-Host "Publishing ${PWD} to ${publishDir}" -ForegroundColor Cyan
remove_dir $publishDir
& dotnet.exe publish --self-contained --runtime win-x64 --output $publishDir --nologo
$expectedFiles = Get-Item "${publishDir}\Presentation*.dll"
$count = ($expectedFiles | Measure-Object).Count
if ($count -gt 0) {
Write-Host "✅ Found ${count} files matching ${publishDir}\Presentation*.dll" -ForegroundColor Green
} else {
Write-Host "⛔ Found NO files matching ${publishDir}\Presentation*.dll" -ForegroundColor Red
}
}
function repro_with_dotnet([int]$dotnetVersion) {
$name = "repro_${dotnetVersion}"
$reproDir = "$PSScriptRoot\${name}"
$fx = "net${dotnetVersion}.0"
Write-Host "Testing ${fx} repro under ${reproDir}" -ForegroundColor Cyan
Write-Host "Creating new ${fx} WPF project in ${reproDir}" -ForegroundColor Cyan
remove_dir $reproDir
& dotnet.exe new wpf --framework $fx --output $reproDir
# disable implicit usings -- prevents `Application` in App.xaml.cs being ambiguous between WPF and WinForms
Write-Host "Disabling <ImplicitUsings> in ${reproDir}\${name}.csproj" -ForegroundColor Cyan
[string]$csprojContent = Get-Content "${reproDir}\${name}.csproj" -Raw -Encoding utf8
$csprojContent = $csprojContent.Replace('<ImplicitUsings>enable<', '<ImplicitUsings>disable<')
Set-Content "${reproDir}\${name}.csproj" $csprojContent -Encoding utf8
Push-Location $reproDir
try {
add_package 'DevExpress.Mvvm' '24.1.5' $DX_NUGET_API
add_package 'DevExpress.Win.Navigation' '24.1.5' $DX_NUGET_API
add_package 'DevExpress.Win.Grid' '24.1.5' $DX_NUGET_API
add_package 'System.ServiceModel.Http' '8.0.0' $NUGET_API
add_package 'System.ServiceModel.Primitives' '8.0.0' $NUGET_API
if ($dotnetVersion -eq 9) {
add_package 'System.Drawing.Common' '9.0.0-rc.1.24451.1' $NUGET_API
add_package 'System.Formats.Asn1' '9.0.0-rc.1.24431.7' $NUGET_API
} else {
add_package 'System.Drawing.Common' '8.0.8' $NUGET_API
add_package 'System.Formats.Asn1' '8.0.1' $NUGET_API
}
publish_and_test "${reproDir}\bin\publish"
# NOTE: adding this package breaks publishing on .NET 9.0 RC1
add_package 'Tulpep.ActiveDirectoryObjectPicker' '3.0.11' $NUGET_API
publish_and_test "${reproDir}\bin\publish"
} finally {
Pop-Location
}
}
repro_with_dotnet 8
repro_with_dotnet 9
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
Commits related to this issue
- Add test for runtime pack profiles Repro for https://github.com/dotnet/sdk/issues/43461 — committed to dsplaisted/sdk by dsplaisted 2 years ago
- Fix runtime pack handling of profiles combined with no profiles Fixes https://github.com/dotnet/sdk/issues/43461 — committed to dsplaisted/sdk by dsplaisted 2 years ago
- Add test for runtime pack profiles Repro for https://github.com/dotnet/sdk/issues/43461 — committed to dotnet/sdk by dsplaisted 2 years ago
- Fix runtime pack handling of profiles combined with no profiles Fixes https://github.com/dotnet/sdk/issues/43461 — committed to dotnet/sdk by dsplaisted 2 years ago
- Add test for runtime pack profiles Repro for https://github.com/dotnet/sdk/issues/43461 — committed to dotnet/sdk by dsplaisted 2 years ago
- Fix runtime pack handling of profiles combined with no profiles Fixes https://github.com/dotnet/sdk/issues/43461 — committed to dotnet/sdk by dsplaisted 2 years ago
This should be fixed in .NET 9 RC2.
I think adding this to the project file should workaround the issue:
Yes, the auto-tagging is somewhat generous in what it considers a NuGet issue. I’ll remove that tag and reopen.