How to make the following connection, so that a value assigned at the build execution is used in a *.cs file:
# command line build execution
msbuild -p:THE_VARIABLE="NEW_VALUE" TheProject.sln
# App.xaml.cs
namespace TheProject
{
sealed partial class App : Application
{
private const string TheVariable = THE_VARIABLE;
}
}
UPDATE 1:
Is there a way to access the csproj as an object from the App.xaml.cs ?
# command line build execution
msbuild -p:MSBUILD_CUSTOM_P="NEW_VALUE" TheProject.sln
# TheProject.csproj
<Target Name="CreateMSBUILD_CUSTOM_P" BeforeTargets="BeforeBuild" Condition=" $(MSBUILD_CUSTOM_P) != '' ">
<PropertyGroup>
<THE_VARIABLE>$(MSBUILD_CUSTOM_P)</THE_VARIABLE>
</PropertyGroup>
</Target>
# App.xaml.cs
namespace TheProject
{
sealed partial class App : Application
{
private const string TheVariable = CSPROJ.THE_VARIABLE;
}
}