I am working with a few different .sln files (that is connected to their own .csproj file in iOS) depending on what project i would like to run in my solution in Visual Studio. In order to work with the different projects I need a way to know what .sln (or .csproj) file is currently "running".
Currently my project is filled with Conditions:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugAppNameOne|iPhone' ">
What i was thinking of doing is to replace that Condition and instead somehow get out the name of either the .sln-or the .csprojfile that is running. My question is, would that be possible and if so how would i get out their names? What i'm thinking is something along these lines:
.sln:
<PropertyGroup Condition=" ’$(TheSlnName)|' == 'SolutionName.AppNameOne.sln'">
.csproj:
<PropertyGroup Condition=" ’$(TheCsProjName)|' == 'SolutionName.iOS.AppNameOne.csproj'">
For .sln files, you can use the following msbuild Macros to figure out what solution you have opened:
$(SolutionFileName): MySolution.sln
$(SolutionPath): D:\MyProjects\MySolution.sln
$(SolutionDir): D:\MyProjects\
$(SolutionName): MySolution
You should be able to use:
<PropertyGroup Condition=" '$(SolutionFileName)' == 'SolutionName.AppNameOne.sln'">
For .csproj files, you can use the following Macros:
$(ProjectFileName): MyLogic.csproj
$(ProjectPath): D:\MyProjects\MyLogic\MyLogic.csproj
$(ProjectDir): D:\MyProjects\MyLogic\
$(ProjectName): MyLogic
You should be able to use:
<PropertyGroup Condition=" '$(ProjectFileName)' == 'SolutionName.iOS.AppNameOne.csproj' ">
You can view MSBuild macros available to your project by viewing the project properties, selecting the Build Events tab, and click on "Edit Pre-Build..." or "Edit Post-Build...". In the window that appears, select the "Macros >>" button, and you'll able to see relevant MSBuild Macro info you could use and what it would evaluate to.
You can also view MSBuild macro documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With