c# - Shared AssemblyInfo for uniform versioning across the solution -
i've read technique: http://blogs.msdn.com/b/jjameson/archive/2009/04/03/shared-assembly-info-in-visual-studio-projects.aspx
basically means create sharedassemblyinfo.cs versioning information assembly, , adding file link projects of solution, actual file resides in 1 location on disk.
my question deals 2 scenarios:
existing solution doesn't use mechanism: there way add shareassemblyinfo projects? (lets have solution 50 projects).
when creating new project, default new assemblyinfo.cs created. i'd link automatically sharedassemblyinfo well.
is there solution this? common practice?
first point solved simple text editor handle several files @ once , find/replace. open of csproj in , replace string <compile include="properties\assemblyinfo.cs" />
with
<compile include="..\sharedassemblyinfo.cs"> <link>properties\sharedassemblyinfo.cs</link> </compile>
my editor of choice editpad pro.
alternatively write absolutely trivial utility that:
var files = directory.getfiles(yoursolutiondir, "*.csproj", searchoption.alldirectories); foreach (var f in files) { string contents = file.readalltext(f); string result = contents.replace("<compile include=\"properties\\assemblyinfo.cs\" />", putsecondstringhere_itisjusttoolong); // :) file.writealltext(f, contents); }
as second question... take @ visual studio custom project templates , i'm not sure worth efforts. should imo write test check instead. simpler , outcome same.
upd: writing tests checking solution/project files against custom rules. basically, sln/csproj format simple enough parseable without efforts. if want have sharedassemblyinfo.cs
linked every project - parse csproj's , check that. put checker in build server , run on each build. have such system working , costs 2 days write saved many more (we have there more sophisticated rules , multi-solution project, worth efforts).
i won't write checking in detail here right (it not short), i'm going write blog post - till end of week. so, if you're interested - check my blog :)
upd: here is.
Comments
Post a Comment