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

Solution filter name as MSBuild variable #6162

Closed
rcmdh opened this issue Feb 12, 2021 · 7 comments · Fixed by #6171
Closed

Solution filter name as MSBuild variable #6162

rcmdh opened this issue Feb 12, 2021 · 7 comments · Fixed by #6171
Assignees
Labels
Feature Request needs-triage Have yet to determine what bucket this goes in.

Comments

@rcmdh
Copy link

rcmdh commented Feb 12, 2021

We are starting to use new solution filters more, including in our build - they're great. We have some conditional elements in our project files dependent on which .sln is being built, can you add support for which .slnf is being built / processed? I had a look through available variables, but couldn't see any that looked like the current .slnf.

@drewnoakes drewnoakes transferred this issue from dotnet/project-system Feb 16, 2021
@benvillalobos benvillalobos added the needs-triage Have yet to determine what bucket this goes in. label Feb 17, 2021
@Forgind
Copy link
Member

Forgind commented Feb 17, 2021

Should be doable. There are only 11 lines with "SolutionName" in them, so probably just add SolutionFilterFileName under the relevant ones, and it'll show up as desired. Does that sound like the solution you want @rcmdh?

@rcmdh
Copy link
Author

rcmdh commented Feb 18, 2021

Sounds great!

@Forgind
Copy link
Member

Forgind commented Apr 28, 2021

@rcmdh, We decided to back this out, unfortunately. See #6325 (comment)

@dotMorten
Copy link

@Forgind Could this be reconsidered? From the sound of it, sounds like it was backed out because you didn't have the user stories to support it. So I'll start:

We have a solution filter that only opens the unit test projects. When opening project using this filter, I want to create a switch that uses nuget package references instead of project references, so that I can properly run my unit test with generated nuget packages, and also validate that these work correctly. The unit test projects won't even build when referencing the unloaded/filtered projects anyway, so naturally we do want to switch over.

For example

<ItemGroup Condition="'$(SolutionFilterName)'=='MySolutionFilter'">
    <PackageReference Include="MyProject" Version="*" />
</ItemGroup>
<ItemGroup Condition="'$(SolutionFilterName)'!='MySolutionFilter'">
    <ProjectReference Include="..\MyProject\MyProject.csproj" />
</ItemGroup>

This makes it super easy for anyone to just open the test solution filter and run the unit tests with the latest build.

Currently we do this with a manually set switch, but would be much easier and less error-prone to tie it to the filter.

@dotMorten
Copy link

This ☝️ a million times

@jamescrosswell
Copy link

I figured since this issue is closed, I'd create a feature request instead:
Solution Filters for target frameworks as well as projects #9159

@Nirmal4G
Copy link
Contributor

Based on the comments, what we need is a concept of Build Profiles for solutions and Target Profiles for projects. But first we need to have a MSBuild native solution file format. Solution files are a concept tied to VS IDE only right now! They are verbose and not human friendly. There's an issue open, requesting to modernize the solution file.

Then again, SolutionFilterName provides an interim relief for those who doesn't want/like to maintain multiple solutions. I know that is a nightmare. Sure, tools like SlnGen makes it easy but still not source control friendly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request needs-triage Have yet to determine what bucket this goes in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants