1

My project file has this:

<PropertyGroup>
  <SolutionName>Foo</SolutionName>
  <AssemblyName>$(SolutionName).$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>

I can get AssemblyName programmatically using GetType().Assembly.GetName().Name.

Is it possible to get SolutionName?

1
  • Why not simply write the name as a string Resource in your project and access it by 'Properties.SolutionName' (assuming you name the Resource 'SolutionName')? Sure, you would have to maintain this resource manually, but the name of the solution usually not changes too often. For a multiproject solution you may put the name in a core project and make the Resources public in order to access from other projects in your solution Commented Jul 12, 2021 at 7:35

1 Answer 1

2

No - not really. The solution file is simply an organization for visual studio. It is not embedded in the built binaries.

What you maybe could do as a workaround is get the solution name in msbuild, and then write it to a file.

See: https://learn.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties?view=msvc-160

$(SolutionName) The base name of the solution. Defined only when building a solution in the IDE.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.