Skip to content

Port Roslyn apphost related changes from release/10.0.1xx to main#3180

Merged
jjonescz merged 6 commits intodotnet:mainfrom
jjonescz:ports
Oct 31, 2025
Merged

Port Roslyn apphost related changes from release/10.0.1xx to main#3180
jjonescz merged 6 commits intodotnet:mainfrom
jjonescz:ports

Conversation

@jjonescz
Copy link
Copy Markdown
Member

@jjonescz jjonescz commented Oct 31, 2025

Clean cherry-picks with no conflicts: #2425, #2464, #2491, #3052, #3069

@dotnet-policy-service dotnet-policy-service bot requested a review from a team October 31, 2025 10:11
@jjonescz jjonescz requested review from jkoritzinsky and removed request for a team October 31, 2025 10:11
@dotnet-policy-service dotnet-policy-service bot requested a review from a team October 31, 2025 10:11
@jjonescz jjonescz requested a review from a team October 31, 2025 10:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for creating native apphost executables for Roslyn compiler tools (csc, vbc, VBCSCompiler) on macOS and other Unix platforms, with proper code signing and file permission handling. It also improves Unix file mode preservation throughout the signing and packaging infrastructure.

  • Creates apphosts for Roslyn compiler tools and applies macOS code signing with entitlements
  • Preserves Unix file permissions across archive extraction/repacking operations
  • Adds chmod operations to ensure Roslyn apphosts have executable permissions

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/sdk/src/Layout/redist/targets/GenerateLayout.targets Adds CreateAppHost task and macOS code signing for Roslyn tools; sets executable permissions
src/sdk/src/Layout/redist/targets/Crossgen.targets Adds chmod command for Roslyn apphosts in crossgen output directory
src/sdk/src/Layout/redist/roslyn-entitlements.plist New entitlements file for macOS code signing with JIT and debugging permissions
src/sdk/src/Layout/Directory.Build.props Defines _RoslynAppHost items for the three compiler DLLs
src/sdk/eng/Signing.props Adds macOS signing configuration for Roslyn apphost executables
src/arcade/src/Microsoft.DotNet.SignTool/src/ZipDataEntry.cs Adds UnixFileMode property to preserve file permissions
src/arcade/src/Microsoft.DotNet.SignTool/src/ZipData.cs Implements Unix file mode preservation; adds logging; fixes typo
src/arcade/src/Microsoft.DotNet.SignTool/src/Configuration.cs Calls SetUnixFileMode when extracting files
src/arcade/src/Microsoft.DotNet.SignTool.Tests/SignToolTests.cs Updates test calls to include logging parameter
src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/src/CpioEntry.cs Adds FilePermissionMask constant
src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/src/ArEntry.cs Adds FilePermissionMask constant

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jjonescz jjonescz enabled auto-merge October 31, 2025 10:31
@jjonescz jjonescz merged commit 0c39299 into dotnet:main Oct 31, 2025
16 of 17 checks passed
@jjonescz jjonescz deleted the ports branch October 31, 2025 12:27
YuliiaKovalova added a commit that referenced this pull request Feb 12, 2026
Similar to Roslyn apphost support (PR #3180), adds:
- CreateAppHost for MSBuild.dll -> MSBuild.exe/MSBuild native executable
- macOS codesign with entitlements plist
- chmod 755 for Unix apphost executables
- MacDeveloperHarden signing for macOS
YuliiaKovalova added a commit that referenced this pull request Mar 4, 2026
Adds SDK layout and installer support for the MSBuild apphost,
following the same pattern as the Roslyn apphost changes (#3180).

Changes:
- Define _MSBuildAppHost item in Directory.Build.props
- Add CreateMSBuildAppHost target in GenerateLayout.targets
  (CreateAppHost, COM .tlb copy on Windows, codesign on macOS)
- Add MSBuild apphost chmod in ChmodPublishDir and Crossgen targets
- Add macOS signing config for MSBuild apphost in Signing.props
- Add msbuild-entitlements.plist for macOS codesigning
- Add Microsoft.Build.Framework.tlb binary for Windows COM support
- Allow .tlb in allowed-vmr-binaries.txt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
YuliiaKovalova added a commit that referenced this pull request Mar 4, 2026
Adds SDK layout and installer support for the MSBuild apphost,
following the same pattern as the Roslyn apphost changes (#3180).

Changes:
- Define _MSBuildAppHost item in Directory.Build.props
- Add CreateMSBuildAppHost target in GenerateLayout.targets
  (CreateAppHost, COM .tlb copy on Windows, codesign on macOS)
- Add MSBuild apphost chmod in ChmodPublishDir and Crossgen targets
- Add macOS signing config for MSBuild apphost in Signing.props
- Add msbuild-entitlements.plist for macOS codesigning
- Add Microsoft.Build.Framework.tlb binary for Windows COM support
- Allow .tlb in allowed-vmr-binaries.txt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dotnet-maestro bot added a commit that referenced this pull request Mar 9, 2026
[main] Source code updates from dotnet/msbuild


 - Add MSBuild apphost installer changes

Adds SDK layout and installer support for the MSBuild apphost,
following the same pattern as the Roslyn apphost changes (#3180).

Changes:
- Define _MSBuildAppHost item in Directory.Build.props
- Add CreateMSBuildAppHost target in GenerateLayout.targets
  (CreateAppHost, COM .tlb copy on Windows, codesign on macOS)
- Add MSBuild apphost chmod in ChmodPublishDir and Crossgen targets
- Add macOS signing config for MSBuild apphost in Signing.props
- Add msbuild-entitlements.plist for macOS codesigning
- Add Microsoft.Build.Framework.tlb binary for Windows COM support
- Allow .tlb in allowed-vmr-binaries.txt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

 - Fix BuildEnvironmentHelper to not use apphost when running via dotnet

TryFromMSBuildAppHost and TryFromAppContextBaseDirectory now check
IsRunningInMSBuildExe before using the MSBuild apphost as the current
MSBuild executable. Without this, worker nodes get launched via the
apphost, changing Environment.ProcessPath to the SDK directory where
dotnet is not present, breaking Process.Start("dotnet") resolution
in tasks like VSTestTask.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

 - Generate Microsoft.Build.Framework.tlb at build time instead of checking in binary

- Remove checked-in .tlb binary from sdk Layout; generate at build time
  via tlbexp.exe during net472 build (CreateTypeLib target)
- Unified tlbexp.exe resolution: registry-based lookup with hardcoded
  fallback, works on both desktop and Core MSBuild (no MSBuildRuntimeType branching)
- Generate both x86 and x64 type libraries in all builds
  (the .tlb ships in both Visual Studio and the .NET SDK on Windows)
- Enable CreateTlb in VMR Windows builds (DotNetBuildSourceOnly != true)
- Include .tlb in Microsoft.Build.Framework NuGet package (lib/net472/)
- SDK layout copies .tlb from NuGet package cache with Exists() guard

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

 - Fix VSTestTask to use DOTNET_HOST_PATH and revert BuildEnvironmentHelper workaround

VSTestTask: Use DOTNET_HOST_PATH environment variable (set by the SDK) to
resolve the dotnet host path, with PATH search as fallback. This is the
proper fix for the 'dotnet not found' error that occurs when MSBuild runs
via the apphost and Environment.ProcessPath changes to the SDK directory.

BuildEnvironmentHelper: Revert the IsRunningInMSBuildExe guard in
TryFromMSBuildAppHost and the context-aware logic in
TryFromAppContextBaseDirectory. These were workarounds for the same issue
and are no longer needed now that VSTestTask resolves dotnet properly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dotnet-maestro bot added a commit that referenced this pull request Mar 9, 2026
[release/10.0.3xx] Source code updates from dotnet/msbuild


 - Add MSBuild apphost installer changes

Adds SDK layout and installer support for the MSBuild apphost,
following the same pattern as the Roslyn apphost changes (#3180).

Changes:
- Define _MSBuildAppHost item in Directory.Build.props
- Add CreateMSBuildAppHost target in GenerateLayout.targets
  (CreateAppHost, COM .tlb copy on Windows, codesign on macOS)
- Add MSBuild apphost chmod in ChmodPublishDir and Crossgen targets
- Add macOS signing config for MSBuild apphost in Signing.props
- Add msbuild-entitlements.plist for macOS codesigning
- Add Microsoft.Build.Framework.tlb binary for Windows COM support
- Allow .tlb in allowed-vmr-binaries.txt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

 - Fix BuildEnvironmentHelper to not use apphost when running via dotnet

TryFromMSBuildAppHost and TryFromAppContextBaseDirectory now check
IsRunningInMSBuildExe before using the MSBuild apphost as the current
MSBuild executable. Without this, worker nodes get launched via the
apphost, changing Environment.ProcessPath to the SDK directory where
dotnet is not present, breaking Process.Start("dotnet") resolution
in tasks like VSTestTask.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

 - Add ExcludeAssets warning for msbuild deps in sdk

 - Generate Microsoft.Build.Framework.tlb at build time instead of checking in binary

- Remove checked-in .tlb binary from sdk Layout; generate at build time
  via tlbexp.exe during net472 build (CreateTypeLib target)
- Unified tlbexp.exe resolution: registry-based lookup with hardcoded
  fallback, works on both desktop and Core MSBuild (no MSBuildRuntimeType branching)
- Generate both x86 and x64 type libraries in all builds
  (the .tlb ships in both Visual Studio and the .NET SDK on Windows)
- Enable CreateTlb in VMR Windows builds (DotNetBuildSourceOnly != true)
- Include .tlb in Microsoft.Build.Framework NuGet package (lib/net472/)
- SDK layout copies .tlb from NuGet package cache with Exists() guard

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

 - Fix VSTestTask to use DOTNET_HOST_PATH and revert BuildEnvironmentHelper workaround

VSTestTask: Use DOTNET_HOST_PATH environment variable (set by the SDK) to
resolve the dotnet host path, with PATH search as fallback. This is the
proper fix for the 'dotnet not found' error that occurs when MSBuild runs
via the apphost and Environment.ProcessPath changes to the SDK directory.

BuildEnvironmentHelper: Revert the IsRunningInMSBuildExe guard in
TryFromMSBuildAppHost and the context-aware logic in
TryFromAppContextBaseDirectory. These were workarounds for the same issue
and are no longer needed now that VSTestTask resolves dotnet properly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants