dotnet / dotnet/sdk

ReadyToRun property changes do not invalidate incremental build outputs

Open
#55,436 5 comments 0 reactions 0 assignees View on GitHub
Area-ReadyToRun untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Description

Hello,

I've faced a weird bug recently and checked multiple times to ensure the behaviour.

I have a .NET 8 program that uses preprocessor directives. They are used only in a small part of the code, to control where is the user data directory location, according to the app release type (`win-installed`, `win-portable`, `linux-installed`, `linux-portable`, etc.).

On my CI/CD, on the same Linux machine, the runner publishes first the `linux-portable` release, then the `linux-installer` release. In this specific sequence, the `linux-installer` has DLLs with reduced size and the app crashes at start. However, if the compilation order is inverted, (`linux-installer` then `linux-portable`), then the DLLs are OK and the app works as expected; the `linux-portable` release is OK too.

### GitHub Actions step

Switching the LINUX_X64_PORTABLE and LINUX_X64_INSTALLER lines below fixes the problem.

```yml
- name: Generate Pororoca Desktop dlls
shell: pwsh
run: |
$arr = @()
if ($env:LINUX_X64_PORTABLE -eq 'true') { $arr += @{ rid="linux-x64"; outputFolder="./out/linux-x64-portable" ; packaging="portable" } };
if ($env:LINUX_X64_INSTALLER -eq 'true'){ $arr += @{ rid="linux-x64"; outputFolder="./out/linux-x64-installer" ; packaging="linux-installers" } };
if ($env:OSX -eq 'true') { $arr += @{ rid="osx-x64"; outputFolder="./out/osx-x64" ; packaging="osx-app" } };
if ($env:WIN_X64_INSTALLER -eq 'true') { $arr += @{ rid="win-x64"; outputFolder="./out/win-x64-installer" ; packaging="nsis" } };
if ($env:WIN_X64_PORTABLE -eq 'true') { $arr += @{ rid="win-x64"; outputFolder="./out/win-x64-portable" ; packaging="portable" } };
if ($env:WIN_X86_INSTALLER -eq 'true') { $arr += @{ rid="win-x86"; outputFolder="./out/win-x86-installer" ; packaging="nsis" } };
if ($env:WIN_X86_PORTABLE -eq 'true') { $arr += @{ rid="win-x86"; outputFolder="./out/win-x86-portable" ; packaging="portable" } };

foreach ($artifact in $arr)
{
$OUTPUT_FOLDER = $artifact.outputFolder
$PUBLISH_SINGLE_FILE = $artifact.packaging -eq "portable";
$WINDOWS_INSTALLER_RELEASE = $artifact.packaging -eq "nsis";
$LINUX_INSTALLER_RELEASE = $artifact.packaging -eq "linux-installers";

Write-Host "Generating Pororoca.Desktop DLLs for $($artifact.rid)."
Write-Host "Output folder: $OUTPUT_FOLDER"
Write-Host "Publish single file: $PUBLISH_SINGLE_FILE"
Write-Host "Win installer release: $WINDOWS_INSTALLER_RELEASE"
Write-Host "Linux installer release: $LINUX_INSTALLER_RELEASE"

[void](New-Item $OUTPUT_FOLDER -ItemType Directory -ErrorAction Ignore);
dotnet publish ./src/Pororoca.Desktop/Pororoca.Desktop.csproj `
--verbosity normal `
--nologo `
--configuration Release `
-p:PublishSingleFile=$PUBLISH_SINGLE_FILE `
-p:PublishForInstallOnWindows=$WINDOWS_INSTALLER_RELEASE `
-p:PublishForInstallOnLinux=$LINUX_INSTALLER_RELEASE `
-p:UITestsEnabled=${env:ENABLE_UI_TESTING} `
--self-contained true `
--runtime $artifact.rid `
--output $OUTPUT_FOLDER;

# let's copy the msquic.dll file next to the generated .exe
if ($artifact.rid -like "*win*")
{
Copy-Item -Path "./src/Pororoca.Desktop/bin/Release/net8.0/$($artifact.rid)/msquic.dll" -Destination $OUTPUT_FOLDER
}

# rename executable
if ($artifact.rid -like "*win*")
{
Rename-Item -Path "$OUTPUT_FOLDER/Pororoca.Desktop.exe" -NewName "Pororoca.exe"
}
else
{
Rename-Item "$OUTPUT_FOLDER/Pororoca.Desktop" -NewName "Pororoca"
}

# set executable attributes (UNIX only)
if (($artifact.rid -like "*linux*") -or ($artifact.rid -like "*osx*"))
{
chmod +x "$OUTPUT_FOLDER/Pororoca"
}
}
env:
ENABLE_UI_TESTING: ${{ inputs.enableUITesting }}
LINUX_X64_PORTABLE: ${{ inputs.produceDesktopLinuxPortableX64 }}
LINUX_X64_INSTALLER: ${{ inputs.produceDesktopLinuxInstallersX64 }}
OSX: ${{ inputs.produceDesktopMacOSX }}
WIN_X64_PORTABLE: ${{ inputs.produceDesktopWinX64Portable }}
WIN_X64_INSTALLER: ${{ inputs.produceDesktopWinX64Installer }}
WIN_X86_PORTABLE: ${{ inputs.produceDesktopWinX86Portable }}
WIN_X86_INSTALLER: ${{ inputs.produceDesktopWinX86Installer }}
```

### Project code

https://github.com/alexandrehtrb/Pororoca/tree/rpmbug

### `.csproj` file

https://github.com/alexandrehtrb/Pororoca/blob/rpmbug/src/Pororoca.Desktop/Pororoca.Desktop.csproj

```xml
True
True
true
partial
true
```

- Portable releases: `PublishSingleFile` = true

### GH Actions logs and RPM content, compilation with bad result

https://gist.github.com/alexandrehtrb/82dcf2a11494f1044a7208c13081a673

### GH Actions logs and RPM content, compilation with good result

https://gist.github.com/alexandrehtrb/91ef85d5b91ac27eddc233b80b0160e0

### Comparison of RPMs contents. Bad result has lighter DLLs (reduced file sizes)

Image

### Reproduction Steps

-

### Expected behavior

-

### Actual behavior

-

### Regression?

_No response_

### Known Workarounds

_No response_

### Configuration

Linux x64, .NET SDK 8.0.421

### Other information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.