dotnet / dotnet/msbuild

[Broken Build]: Setting BaseOutputPath in Directory.Build.props Breaks Solution Loading

Open
#9,445 7 comments 0 reactions 1 assignee Assigned to @rainersigwald View on GitHub
needs-triage
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

I encountered an issue where adding a `Directory.Build.props` file with a custom `` breaks the loading of files and references in the entire solution. The goal is to set the output of all projects to the solution root.

### Steps to Reproduce

Try to build [ConsoleApp10.zip](https://github.com/dotnet/msbuild/files/13438074/ConsoleApp10.zip)

#### or do it manually:
Create a `Directory.Build.props` file with the following content:

```xml


$(MSBuildThisFileDirectory)


```

### Expected Behavior

The solution should load normally, with all projects outputting their build results to the solution's root directory.

### Actual Behavior

After adding the Directory.Build.props file, the solution fails to load correctly. No files are loaded, and no references are resolved.

msbuild doesn't see the `Program.cs` file.
```
PS D:\ConsoleApp10> tree /f
Folder PATH listing for volume Data
Volume serial number is 2221-5E74
D:.
│ ConsoleApp10.sln
│ Directory.Build.props

└───ConsoleApp10
ConsoleApp10.csproj
Program.cs

PS D:\ConsoleApp10> dotnet build
MSBuild version 17.7.3+4fca21998 for .NET
Determining projects to restore...
Restored D:\ConsoleApp10\ConsoleApp10\ConsoleApp10.csproj (in 62 ms).
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [D:\ConsoleApp10\ConsoleApp10\ConsoleApp10.csproj]

Build FAILED.

CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [D:\ConsoleApp10\ConsoleApp10\ConsoleApp10.csproj]
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.04
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.