question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Solution isn't updated when excluding project with modifier

See original GitHub issue

Steps to Reproduce

  1. Create a .template.config for a solution with multiple projects.
  2. Add a symbol/modifier to remove one of these projects.
  3. dotnet new, and ensure that the symbol for removing the project is set to true.

Expected Behavior

Because I am excluding an entire directory with a csproj, I expect the folder containing this project to not unfold, and that the solution is updated to remove this project.

Actual Behavior

The folder containing the excluded csproj is not unfolded (as expected), but the solution is not updated to reflect this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
seancpeterscommented, Jun 19, 2017

For conditionally including / excluding content from a .sln file, the syntax for the conditional statements is:

//#if (<condition>)
//#elseif (<condition>)
//#else
//#endif

…and the corresponding //// versions for conditional uncommenting in conjunction to including or excluding the content.

I created a small solution template with 2 projects in it, and added conditioning based on a boolean parameter called “useOther”. I believe this example will satisfy your needs, @pierceboggan :


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26613.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Company.ClassLibrary1", "MultiProjectTest\Company.ClassLibrary1.csproj", "{8FD9C741-9EC7-4D23-AE19-8AAFA34F9402}"
EndProject
//#if (useOther)
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OtherProject", "OtherProject\OtherProject.csproj", "{6131A358-96A3-48CF-9DA0-5C1A6EB67BEA}"
EndProject
//#endif
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{8FD9C741-9EC7-4D23-AE19-8AAFA34F9402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{8FD9C741-9EC7-4D23-AE19-8AAFA34F9402}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{8FD9C741-9EC7-4D23-AE19-8AAFA34F9402}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{8FD9C741-9EC7-4D23-AE19-8AAFA34F9402}.Release|Any CPU.Build.0 = Release|Any CPU
//#if (useOther)
		{6131A358-96A3-48CF-9DA0-5C1A6EB67BEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{6131A358-96A3-48CF-9DA0-5C1A6EB67BEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{6131A358-96A3-48CF-9DA0-5C1A6EB67BEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{6131A358-96A3-48CF-9DA0-5C1A6EB67BEA}.Release|Any CPU.Build.0 = Release|Any CPU
//#endif
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {09C5699D-670E-48BB-9CCE-5A20A387CC9B}
	EndGlobalSection
EndGlobal

With this setup, if my useOther symbol is set to false, the “OtherProject” statements are excluded from the .sln file.

If you use the same condition(s) in the .sln files as in the sources section of the template.json, the output should be as expected.

Please let me know if you run into any issues using this approach, and we can work through them together to get the results you expect.

1reaction
mlorbetskecommented, Jun 19, 2017

Yep, that’d be the approach - to add conditioning to the solution file that keys on the same symbol that’s used in the modifier

@seancpeters can you assist with the syntax for conditions in sln files?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this image not staying in place when using the UV ...
Use "override image" option in the modifier. Each empty has been moved and scaled to fit the image texture at the wanted location....
Read more >
Visual Studio 2015, can't change access modifier of new ...
This problem is a known bug in Asp.net Core projects and access modifier is on public by default and you can not change...
Read more >
Project Solution (.sln) file - Visual Studio (Windows)
A solution is a structure for organizing projects in Visual Studio. ... This value isn't updated so as to lessen churn in the...
Read more >
Ctrl-A for applying modifier under cursor (2.91) not active (2.92 ...
Hi folks! Since 2.92 there is a new concept of active modifier, which was introduced due to new geometry nodes project.
Read more >
How to Use the SHRINKWRAP Modifier in Blender ... - YouTube
In this video, learn how to use the Blender Shrinkwrap modifier to ... surface modifier 4:57 - Shrinkwrap Wrap method - Project 6:23 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found