The Question
How do I copy my class library assemblies to my Core Mvc project at build time?
The Problem Statement
I am working on porting an Onion Architecture project to Asp.Net Core. In line with the design approach, I have the following:
Some.Bootstrapper
- Startup.cs
Some.WebApi
- Program.cs
In Program.cs, I am referencing the Bootstrapper assembly to call my Starup.cs file:
.UseStartup("Some.Bootstrapper")
However, I am unable to figure out how to output the Bootstrapper assembly files to my WebApi project. According to Onion, I should not be making a direct reference to Some.Bootstrapper from Some.WebApi. In my previous Asp.Net project, I used the properties window of my Bootstrapper project to set the output path (e.g: ..\Some.WebApi\bin\". However, in Asp.Net Core, I understand that I won't be able to set the output path until we move to msbuild. It seems this guy has been able to skin the cat. I am not exactly sure how.
Expected Behavior
I should be able to call .UseStartup("Some.Bootstrapper") without making a direct assembly reference.
Feedback appreciated.
Ultimately, using a post-compile script in my Bootstrapper project to xcopy my DLLs to WebApi was the best solution for me.
"scripts": {
"postcompile": [
"xcopy /I /F /Y %compile:OutputDir%\\. ..\\Some.WebApi\\bin\\%compile:Configuration%\\netcoreapp1.0\\" ]
}
Credit goes to Binoy in this thread