Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use out of source .settings file #11157

Open
duckdoom5 opened this issue Dec 17, 2024 · 1 comment
Open

Unable to use out of source .settings file #11157

duckdoom5 opened this issue Dec 17, 2024 · 1 comment

Comments

@duckdoom5
Copy link

duckdoom5 commented Dec 17, 2024

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.

  <ItemGroup>
    <Compile Include="..\Source\Properties\Settings.Designer.cs">
      <Link>Properties\Settings.Designer.cs</Link>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <None Include="..\Source\Properties\Settings.settings">
      <Link>Properties\Settings.settings</Link>
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
  </ItemGroup>

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
  • 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

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

@duckdoom5
Copy link
Author

Also, the same applies to the file called launchSettings.json. This file only works if it's inside of the solution folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant