dotnet / dotnet/roslyn

Compiler task is passing `/generatedfilesout` even though it didn't create the directory

Open
#73,075 9 comments 0 reactions 0 assignees View on GitHub
Area-Compilers Bug
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

`Could not find a part of the path` makes it sound like the output directory is not present. But the compiler and compiler tasks should create the directory (both the /generated directory and the individual generator output directories within it).

https://github.com/dotnet/roslyn/blob/d5b9aaa7e984890c9a8d967bde68d1c62d4858fa/src/Compilers/Core/MSBuildTask/Microsoft.Managed.Core.targets#L339-L340

https://github.com/dotnet/roslyn/blob/d5b9aaa7e984890c9a8d967bde68d1c62d4858fa/src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs#L1173-L1176

However it looks like the task linked above didn't run in the cdacreader build. binlog says:

> Target Name=CreateCompilerGeneratedFilesOutputPath Project=cdacreader.csproj
> Target "CreateCompilerGeneratedFilesOutputPath" skipped, due to false condition; ('$(EmitCompilerGeneratedFiles)' == 'true' and !('$(DesignTimeBuild)' == 'true' OR '$(BuildingProject)' != 'true')) was evaluated as ('true' == 'true' and !('' == 'true' OR 'false' != 'true')).

I'm confused by this :) as `'true' == 'true' and !('' == 'true' OR 'false' != 'true')` seems like it ought to evaluate to ~~true~~. *false, my conditional logic brain wasn't working.* I think the BuildingProject property should be true instead of false in order for the directory to be created here. What controls that?

I think maybe the compiler task has a bug here. Basically it feels like we should only be passing a `/generatedfilesout` argument to the compiler if we also ran target `CreateCompilerGeneratedFilesOutputPath`. But it looks like the current build task permits us to pass that argument without running the target.

_Originally posted by @RikkiGibson in https://github.com/dotnet/source-build/issues/4335#issuecomment-2062537783_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.