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:

  1. add global.json file in top-level directory contains projects. in projects section, list directories contain source-code, example:

    {     "projects": [ "src", "test" ],     "sdk": {         "version": "1.0.0-rc1-final"     } } 
  2. in same directory contains global.json execute dnu wrap each existing .csproj project.

    dnu wrap src/my.project/my.project.csproj   

    this should create directory wrap containing project.json files 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 wrap directory added projects section in global.json.

  3. in solution, add new aspnet project , add reference wrapped project. add:

    "my.project": "" 

    to dependencies section. aspnet should automatically pick global.json file in root directory, , projects in directories listed there, including wrap directory.

  4. now you're go - can use classes my.project, step them while debugging, go definition, etc. note in solution, still have old csproj.

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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -