c# - adding reference .net core web api project on vscode -


i'm developing webapi project on vscode .net core target framework.. have scenario part of code (db interactions , common utils) going part of many other separate projects particular webapi project. decided code separately in folder project..

yet can't figure out how going this.. whether project reference or output file dependency, doesn't matter, couldn't figure out use second project in first one.. want build library compatible .net core, , use in many other .net core projects.

i need guideline , best practice suggestions here.

update :

i think i've found way , seems working now.. still want know other , better options one.

1- adding <projectrefence> firstproject.csproj file :

<projectreference include="..\secondproject\secondproject.csproj"></projectreference> 

2- add project.json file firstproject , setting dependency secondproject.

{     "dependencies": {         "secondproject": {             "target": "project"                     }     } } 

3- dotnet restore , build.

4- restart vscode proper intellisence.

depending on os / ide / version of .net core, may or may not need csproj update. think need them present .net core 2+ / vs17+, , other permutations of tooling.

you may need expand dependencies block. found based on os , ide, needed call out of dependencies; didn't carry on transitively. example, ended block when referencing project, things compiling:

"dependencies": { "microsoft.netcore.app": { "version": "1.1.0", "type": "platform" }, "netstandard.library": "1.6.1", ... "otherprojectnamehere": { "target": "project" } },

your specific set of dependencies vary.

you may need make adjustments frameworks block in similar spirit.

a more rigorous option can consider put library / secondproject own repository, , work nuget package. if library you're going use across many projects or many teams, may benefit package reference rather project reference. you'd gain:

  • version numbers library, can more answer questions "are changes library included in build of app", , of peripheral benefits go versioning.
  • separation of concerns, ensure library stays general purpose , doesn't end hard-coded stuff 1 app.
  • more add references (just version number, else)
  • more share library other teams. ... , more.

in short, libraries products, too. may want treat one, if you're in company / situation makes sense.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -