Console Projects fail to compile with <ArtifactsPath>$(MSBuildThisFileDirectory)
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Issue Description
The CSC Roslyn compile fails to build with "Program does not contain a static 'Main' method suitable for an entry point" despite it being entirely valid, Just because the `$(ArtifactsPath) == $(MSBuildThisFileDirectory)`.
### Steps to Reproduce
```sh
dotnet new console
dotnet new buildprops --use-artifacts
dotnet build
# Builds as expected
sed -i 's/artifacts//' Directory.Build.props # Rewrite $(MSBuildThisFileDirectory)artifacts -> $(MSBuildThisFileDirectory)
dotnet build
# Build fails due to missing Main
```
It works fine when instead using `$(MSBuildThisFileDirectory).`
```sh
dotnet new buildprops --use-artifacts --force
sed -i 's/artifacts/./' Directory.Build.props
dotnet build
# Build succeeds and it behaves as expected
```
### Expected Behavior
It should compile just fine with the artifact directories `bin/obj/package/etc...` co-located next to the Directory.Build.props
### Actual Behavior
It Fails to compile with
```
Restore complete (0.4s)
ArtifactBuildReproduction failed with 1 error(s) (0.3s)
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point
Build failed with 1 error(s) in 1.1s
```
### Analysis
No Idea
### Versions & Configurations
dotnet 9.0.306
msbuild 17.14.28.46601
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.