dotnet / dotnet/msbuild

Unable to use out of source .settings file

Open
#11,157 1 comment 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

Not sure if this is the right place to report this, but I found #2782 which seemed similar.

So I have a c# project, generated with CMake. The solution files are generated out of source (meaning the source files are not in the solution directory).

This means CMake generates code like this, which uses link tags to include the file in the project.

```


Properties\Settings.Designer.cs
True
True
Settings.settings



Properties\Settings.settings
SettingsSingleFileGenerator
Settings.Designer.cs


```

When this method is used, the `Settings.Designer.cs` fails to update. The `Settings.settings` file contains a setting called ` TestSetting` which does not get added to the auto generated file.

This means I'm forced to somehow place these files inside of the solution directory with CMake and makes it impossible to update the settings file since I'd need to copy it out of source every time I make a change. Or find some other hacky workaround like copy the `Settings.settings` file from source to solution on edit.

### Steps to Reproduce

- Open the repro project here: [SettingsBug.zip](https://github.com/user-attachments/files/18166015/SettingsBug.zip)
- Note the separation of the `Settings.*` source files from the solution
- Open the solution
- Open the `Settings.settings` file and observe the setting called `TestSetting`
- Open the `Settings.Designer.cs` file and observer the property code for this setting is missing
- Run the project and observe it fails to compile due to the missing property code

* Additionally note that the `Run Custom Tool` context menu item also fails to update the file
![Image](https://github.com/user-attachments/assets/cac7e664-775f-4203-8580-d7c1dbbd31d5)

### Expected Behavior

The `Settings.Designer.cs` file is automatically generated and updated

### Actual Behavior

The `Settings.Designer.cs` file is **not** automatically generated and updated

### Analysis

My guess is that the code that generates/updates the designer file uses a path mapping that does not follow the path link defined in the `.csproj`.
Also note that updating the `Settings.settings` file, does properly update the `App.config` file, so there it does work as expected.

### Versions & Configurations

MSBuild version 17.12.12+1cce77968 for .NET Framework
17.12.12.57101

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.