Skip to content

AddProjectConfigurationRule does not affect if solution has no custom BuildType and Platform #112

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

Open
itn3000 opened this issue Mar 18, 2025 · 0 comments

Comments

@itn3000
Copy link

itn3000 commented Mar 18, 2025

Overview

When ProjectConfigurationRule is added to SolutionModel by AddProjectConfigurationRule and output as slnx,
no affect on output slnx.

Environment

  • architecture: x64
  • dotnet sdk: 9.0.201
  • dotnet runtime: 9.0.3
  • Microsoft.VisualStudio.SolutionPersistence: 1.0.52 and github latest source( 19c3ca7 )

Steps to reproduce

  1. create new console project and add Microsoft.VisualStudio.SolutionPersistence package
  2. add following minimal code
  3. check output slnx

here is the code:

static async Task MinimalReproducible()
{
    var solutionModel = new SolutionModel();
    var proj = solutionModel.AddProject("app1/app1.csproj");
    // comment out following three lines, then <Build Solution="Debug|*" Project="false"/> element will be added under app1/app1.csproj's element
    // solutionModel.AddBuildType("Release");
    // solutionModel.AddBuildType("Debug");
    // solutionModel.AddPlatform("Any CPU");
    proj.AddProjectConfigurationRule(new ConfigurationRule(BuildDimension.Build, "Debug", "Any CPU", "false"));
    await SolutionSerializers.SlnXml.SaveAsync("../test.slnx", solutionModel, default);
}

Expected result

<Build Project="false"/> is added under <Project Path="app1/app1.csproj">

<Solution>
  <Project Path="app1/app1.csproj">
    <Build Solution="Debug|*" Project="false" />
  </Project>
</Solution>

Actual result

there is no <Build> element under app1/app1.csproj's element.

<Solution>
  <Project Path="app1/app1.csproj" />
</Solution>

Additional

I tested on latest source on github(commit hash: 19c3ca7 ), I got same output.
uncomment AddBuildType and AddPlatform and run, output the following slnx(configurations of BuildType and PlatformType is disappeared?);

<Solution>
  <Project Path="app1/app1.csproj">
    <Build Solution="Debug|*" Project="false" />
  </Project>
</Solution>
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