Saturday 15 August 2015

c# - Conditional project path variables in VisualStudio solutions -



c# - Conditional project path variables in VisualStudio solutions -

we have big c# programme split 2 major groups: kernel libraries , (customer) specific applications & services.

our tfs construction (simplified) this:

kernel

dlvp release 1 release 2 release 3 ...

customera

dlvp release

customerb

dlvp release

we used nugets compile , distribute our kernel code , include client applications. can move new version/release. however, not content dll's. want have total debugging , editing experience everywhere.

you can include kernel projects in client solutions, have reference release x, if want move new release, have alter every solution , project file every costumer, lot (n customers x m services/programs = lot)

i read can utilize environment variabels alter values in .sln & .csproj files, have more controllable across developers. prefer referencing shared variable can stored in tfs.

i've made little .sln file clarify:

microsoft visual studio solution file, format version 11.00 # visual studio 2010 project("{fae04ec0-301f-11d3-bf4b-00c04f79efbc}") = "consoleapp", "consoleapp\consoleapp.csproj", "{b6b9ae41-99ed-47ce-b35c-f693c5f5f736}" endproject project("{fae04ec0-301f-11d3-bf4b-00c04f79efbc}") = "libkernel", "..\..\release 1\libkernel\libkernel\libkernel.csproj", "{439bd82b-340d-4d69-b367-e52e0df27983}" endproject

i want alter part:

"libkernel", "....\ release 1 \libkernel\libkernel\libkernel.csproj", "{439b....}"

into

"libkernel", "....\ {customera.currentrelease} \libkernel\libkernel\libkernel.csproj", "{439b....}"

something (and .csproj files), if improve approaches, i'm glad hear them.

thx lot

we utilize kind of thought referencing assemblies located in particular location per user needs.

first need save external file content shown below..

suppose filename buildpath.xml

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" > <propertygroup> <assemblydirlocation>c:\inetpub\wwwroot\siteinstance\website</assemblydirlocation> </propertygroup> </project>

next import config in .csproj. believe shall work in .sln files also

for proper understanding have included surrounding text here .csproj file

<?xml version="1.0" encoding="utf-8"?> <project toolsversion="12.0" defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <import project="$(msbuildextensionspath)\$(msbuildtoolsversion)\microsoft.common.props" condition="exists('$(msbuildextensionspath)\$(msbuildtoolsversion)\microsoft.common.props')" /> <import project="..\build\buildpath.xml" condition="exists('..\build\buildpath.xml')" /> <propertygroup> <configuration condition=" '$(configuration)' == '' ">debug</configuration> <!-- more text -->

notice next line above text

<import project="..\build\buildpath.xml" condition="exists('..\build\buildpath.xml')" />

usage:

in .csproj or .sln file have imported above file, can write below macro replace value. notice tag name matches macro written i.e. $(assemblydirlocation).

<itemgroup> <reference include="site.kernel"> <hintpath>$(assemblydirlocation)\bin\site.kernel.dll</hintpath> <private>false</private> </reference> </itemgroup>

whenever create changes in buildpath.xml external file need reload referencing project.

i hope clear , helpful.

c# visual-studio versioning solution csproj

No comments:

Post a Comment