After consuming .net standard projects in a .net framework(4.6) console application, the dependencies of the .net standard projects are not copied into the output directory. This results in run time error of missing dlls. The "copy local" property is already true for the referenced projects. One possible solution is to add all the dependencies again in the console application, but is not a good idea. Is there a better solution to this?
Asked
Active
Viewed 3,971 times
2 Answers
31
After going through an article by Scott Hanselman, below solution worked like a charm.
Add below line in the first "PropertyGroup" tag of the .net framework console application's ".csproj" file
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
There will not be any need to add again the .net standard projects' nuget dependencies in the console application.
![](../../users/profiles/1640234.webp)
tech-y
- 1,451
- 2
- 12
- 25
-
That Hanselman article is great - thanks for the link – dlchambers Oct 27 '20 at 11:46
-
Sadly, adding the above xml to my .csproj causes the project to fail to load – dlchambers Oct 27 '20 at 11:57
-1
Another answer is to publish the project:
dotnet publish -o path/to/output/folder
![](../../users/profiles/1930712.webp)
FrozenKiwi
- 725
- 5
- 20