c# - Build, pack up and deploy for multiple platform targets -


i'm looking forward setup environment/configuration allows me build , deploy custom library multiple platforms / targets, such build configurations and/or .net framework versions. this, i've laid out following structure:

myproject.sln src\    file1.cs    file2.net30.cs    myproject.net40.csproj    myproject.net30.csproj    myproject.net45.csproj 

all project files included in solutions , built @ once. each project contains source files framework targets and/or files different .net versions compiled conditionally (using compiler directives, e.g. net35, net34_or_greater). additionally, each project file contains following msbuild directives:

<outputpath>bin\$(configuration)\$(platform)\$(targetframeworkversion)\$(targetframeworkidentifier)\</outputpath> <baseintermediateoutputpath>obj\$(configuration)\$(platform)\$(targetframeworkversion)\$(targetframeworkidentifier)\</baseintermediateoutputpath> <documentationfile>bin\$(configuration)\$(platform)\$(targetframeworkversion)\$(targetframeworkidentifier)\$(assemblyname).xml</documentationfile> 

this allows me build them @ once routing output different directories.

now, that's building. however, i'm stuck deployment, related nuget. i've created .nuspec include every dependency manually:

<file src="bin\release\anycpu\v4.0\myproject.dll" target="lib\net40-client\eit.foundation.dll" /> <file src="bin\release\anycpu\v4.0\myproject.xml" target="lib\net40-client\eit.foundation.xml" /> <file src="bin\release\anycpu\v4.5\myproject.dll" target="lib\net45\myproject.dll" /> 

this works fine, tedious. first question: is there way hook files automagically?

and second problem: libraries have nuget dependencies themselves. project dependencies, packages.config automatically created in same folder project when downloading nuget dependencies. packages.config not contains dependency or version used in project, framework version of dependency required. bit of problem since every project file (for each framework target) resides in same folder, need share same packages.config file somehow. i'd tried relocating project files different structure this:

myproject.sln target\    net40\myproject.net40.csproj src\    file1.cs 

... i'm unable preserve folder structure in source folder (if there's any) because project files allow me include files, not folders (they being automatically included.) is there way around or nuget not suited multi-target builds?

whilst nuget supports creating nuget package particular project targeted single projects. command nuget pack yourproject.csproj suspect not you. using .nuspec file way working.

nuget supports multiple projects in same directory if rename packages.config file. each packages.config file should named after project. in example following should work:

  • packages.myproject.net40.config
  • packages.myproject.net30.config
  • packages.myproject.net45.config

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -