visual studio 2015 - Shared Class Library References for ASP.NET 5 beta 7 -
in our current environment, have shared common library (c# class library .net 4.5.1 csproj) projects referenced both asp.net , console applications. looking upgrading 1 of our web projects asp.net 5 start testing out of new changes coming.
since can't project reference in asp.net 5 old csproj library type, have reference library it's compiled dll , remove dnxcore50 project.json (which fine us). however, own shared library source , bring down updates in our dev environment modifications , changes needed dll. asp.net 5 puts dll inside of lib directory , not use path csproj directory.
what if have asp.net & console csproj apps along asp.net 5 apps needing share common code library without having maintain 2 code bases? recommend build task compile common library project , replace reference dll in lib before compiling asp.net 5 project or instead setup local nuget repo our shared library since project references out of question csproj? we're shared team of code in tfs whatever needs replicated else.
if shared code doesn't change often, go shared nuget repository. way, benefits of using nuget packages: versioning, easy restoration, etc. solution can have less projects , compile faster. if shared code changed, going through pack-push-restore process painfull.
there 1 other way - dnu has handy command named wrap. wraps existing .csproj files project.json files can referenced aspnet5 projects.
you can this:
add
global.jsonfile in top-level directory contains projects. inprojectssection, list directories contain source-code, example:{ "projects": [ "src", "test" ], "sdk": { "version": "1.0.0-rc1-final" } }in same directory contains
global.jsonexecutednu wrapeach existing.csprojproject.dnu wrap src/my.project/my.project.csprojthis should create directory
wrapcontainingproject.jsonfiles wrap.csprojs. sample file looks this:{ "version": "1.0.0-*", "frameworks": { "net45": { "wrappedproject": "../../src/my.project/my.project.csproj", "bin": { "assembly": "../../src/my.project/obj/{configuration}/my.project.dll", "pdb": "../../src/my.project/obj/{configuration}/my.project.pdb" } } } }note
wrapdirectory addedprojectssection inglobal.json.in solution, add new aspnet project , add reference wrapped project. add:
"my.project": ""to
dependenciessection. aspnet should automatically pickglobal.jsonfile in root directory, , projects in directories listed there, includingwrapdirectory.now you're go - can use classes
my.project, step them while debugging, go definition, etc. note in solution, still have oldcsproj.
you can find sample code here: https://github.com/heavymetaldev/aspnet5-wrap.
i suppose may little complicated if have custom things in projects, conditional compilation, custom includes, etc.
Comments
Post a Comment