Skip to content

Backport issue #115951 into .NET 9 and .NET 8 so it work with VS 2026 #121211

@DamianSuess

Description

@DamianSuess

Description

When publishing C# applications with AOT and only VS 2026 is installed, the findvcvarsall.bat file throws an error. Please implement #115951 into .NET 8 and .NET 9, as the Microsoft.DotNet.ILCompiler toolset throws errors when publishing applications

Reproduction Steps

Steps to Reproduc

  1. Only install VS 2026
  2. Install .NET 9
  3. Include the "Desktop Development with C++" workload via installer
  4. Include the ".NET Desktop Development" workload via installer
  5. Publish an application with AOT
    • dotnet publish TestApp.csproj /p:PublishProfile=TestApp/PublishProfiles/win-x64.pubxml

Sample win-x64.pubxml

<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project>
  <PropertyGroup>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <PublishDir>../publish/cli/win-x64</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <_TargetId>Folder</_TargetId>
    <TargetFramework>net9.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishReadyToRun>false</PublishReadyToRun>
    <PublishSingleFile>false</PublishSingleFile>
  </PropertyGroup>
</Project>

Expected behavior

Not to fail.

Use the methodology in, #115951

Actual behavior

Throws error stating, "Make sure to install the Desktop Development for C++ workload. For ARM64 development also install C++ ARM64 build tools." Even through they are already installed.

Regression?

No response

Known Workarounds

Manually edit Line 18 in, findvcvarsall.bat, removing the line -version [16^,18^) ^

FOR /F "tokens=*" %%i IN (
    '"%vswherePath%" -latest -prerelease -products * ^
    -requires Microsoft.VisualStudio.Component.VC.Tools.%toolsSuffix% ^
    -version [16^,18^) ^
    -property installationPath'
) DO SET vsBase=%%i

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions