Skip to content

$(RepoRoot) is missing trailing slash so local builds fail #32615

@SteveSandersonMS

Description

@SteveSandersonMS

Not sure if this is a known issue yet, but it seems not to work to run dotnet build in almost any of the project directories under src/Components. Most likely other projects will fail too.

For some reason, $(RepoRoot) evaluates to a location without a trailing slash, even though code in the top-level Directory.Build.props explicitly generates a value with a trailing slash. This makes many project references and <Import> declarations fail to resolve correctly, since they assume there would be a trailing slash after $(RepoRoot). Also for some reason, this doesn't affect build.cmd - perhaps it overrides the reporoot in some way.

As a workaround, you can do dotnet build /p:RepoRoot=C:\your\path\to\aspnetcore\.

Update

I tracked down the source of the bad value: it's the build.cmd scripts, as they set an environment variable called RepoRoot with the non-slash-ended value. Then the MSBuild logic only creates a value with a trailing slash if there isn't already a value, but there is already a value because of the env var.

So the remaining question is: how did this ever work in the past? I see that build.cmd hasn't changed recently. One possible clue is this comment from the top Directory.build.props:

<!-- $(RepoRoot) is normally set globally and Arcade overrides it to ensure a trailing slash. -->

Maybe Arcade no longer has this behavior of overriding it to ensure a trailing slash.


Older report

This seems to be a recent regression. Repro:

  • cd src\Components
  • git checkout main
  • git reset --hard
  • build.cmd
  • cd Samples\BlazorServerApp
  • dotnet build

Expected: builds the project
Actual: fails with errors like this:

C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\BlazorServerApp.UnifiedAssembly.Info.g.cs(1,30): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\BlazorServerApp.csproj]
C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Pages__Host_cshtml.cs(4,30): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\BlazorServerApp.csproj]
C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\Program.cs(6,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\BlazorServerApp.csproj]
C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\Program.cs(7,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\git\dotnet\aspnetcore\src\Components\Samples\BlazorServerApp\BlazorServerApp.csproj]

Something to do with source generators, it appears.

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Componentsarea-infrastructureIncludes: MSBuild projects/targets, build scripts, CI, Installers and shared frameworktask

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions