Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerous failures while building aspnetcore tests in VMR #60095

Open
NikolaMilosavljevic opened this issue Jan 29, 2025 · 0 comments
Open

Numerous failures while building aspnetcore tests in VMR #60095

NikolaMilosavljevic opened this issue Jan 29, 2025 · 0 comments
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework

Comments

@NikolaMilosavljevic
Copy link
Member

Here are the errors encountered when we tried to enable building tests in VMR:

At first this was failing due to missing test certificates, required by various tests. We are skipping the creation of those certificates due to this false condition:

<!-- This task only tries to generate a certificate if there is none existing at the location provided as path. -->
<GenerateTestDevCert
CertificatePath="$(_DevCertPath)"
Condition="'$(MSBuildRuntimeType)' == 'core'">
</GenerateTestDevCert>

MSBuildRuntimeType is set to Full due to: https://github.com/dotnet/dotnet/blob/81f0f65d674c3aebd3c1ce78f2e5d831d32980f8/repo-projects/aspnetcore.proj#L19-L21

    <!-- aspnetcore must be built with desktop msbuild but defaults to dotnet build. -->
    <BuildArgs Condition="'$(BuildOS)' == 'windows'">$(BuildArgs) -msbuildEngine vs</BuildArgs>
    <ForceDotNetMSBuildEngine>false</ForceDotNetMSBuildEngine>

This requires enabling GenerateTestDevCert task for .NET FX. Either by shelling out to use external tooling, or reuse some of the code from CertificateManager.

With test certificates available, we get the following failures:
C:\git\dotnet\src\aspnetcore\src\ProjectTemplates\TestInfrastructure\PrepareForTest.targets(118,5): error MSB3030: Could not copy the file "DontDareMutateThisSDKdotnet.exe" because it was not found. [C:\git\dotnet\src\aspnetcore\src\ProjectTemplates\test\Templates.Blazor.WebAssembly.Auth.Tests\Templates.Blazor.WebAssembly.Auth.Tests.csproj]

The root cause is in this section that talks about not running tests on source-build:

<!-- The location of the local installation of the .NET Core shared framework. -->
<PropertyGroup>
<LocalDotNetRoot>$(RepoRoot).dotnet\</LocalDotNetRoot>
<LocalDotNetRoot Condition="'$(DotNetBuild)' == 'true'">DontDareMutateThisSDK</LocalDotNetRoot>
<!--
Override the SDK default and point to local .dotnet folder. This is done to work around
limitations in the way the .NET SDK finds shared frameworks and targeting packs. It allows
tests to use the shared frameworks and targeting packs that were just built.
However, source-build needs this to not happen while building projects that rely on the
AppHost framework pack. Source-build installs an SDK in a custom location outside this
repository, and setting NetCoreTargetingPackRoot to a different location causes source-build
to restore the AppHost pack as a prebuilt rather than using the one that's present in the SDK.
Source-build doesn't run tests, so the property is simply conditioned out.
-->
<NetCoreTargetingPackRoot Condition="'$(DotNetBuild)' != 'true'">$(LocalDotNetRoot)packs\</NetCoreTargetingPackRoot>
<!-- This is not correct and needs attention eventually. This is primarily used to find the nethost headers in the apphost pack.
These should be coming from a restored apphost pack, rather than a hard-coded local SDK. In fact, aspnetcore
should not rely on a local SDK or mutating one to build. -->
<NetCoreTargetingPackRoot Condition="'$(DotNetBuild)' == 'true'">$(DotNetRoot)packs\</NetCoreTargetingPackRoot>
</PropertyGroup>

One idea for fixing this: dotnet/sdk#44843 (comment)

For repro, add /p:DotNetBuildTests=true to your Windows VMR build command, i.e.: build -prepareMachine -c Release /p:TargetOS=windows /p:TargetArchitecture=x64 /bl /p:DotNetBuildTests=true

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework
Projects
None yet
Development

No branches or pull requests

1 participant