I have some html pages that I keep in a separate project which I specify to copy to output. This project is referenced by the main SS app.
When debugging following code inside a service call
var context = new TemplateContext
VirtualFiles = base.VirtualFiles,
var page = context.GetPage("emails/verify-email");
I get a page at path was not found error, looking at the virtualfiles properties it looks like it is only picking up html files from the project directory and not the bin\Debug\netcoreapp2.0\ which i expected when debugging.
Are there other additional properties I need to set in order for it to pick up html files from the bin\debug\netcoreapp2.0 directory?
This is the same approach TechStacks uses to access its Template Files which is works in both development and when the App is published:
Are you copying your emails to the deploy directory on publish?
Yes the emails are being copied to the debug directory.
I've added a example proj on github https://github.com/laitang2000/test-sharedemailtemplates
If you run the project and then call http://localhost:5000/links you can see my issue.
There are no /emails in your host project folder so that's not going to work during development.
and when I publish the app:
$ npm run publish
Then run the published application:
$ cd bin\Release\netcoreapp2.0
$ dotnet emailtemplate.dll
The http://localhost:5000/links returns the links without Exception as expected.
What is the best way to get this to work in development?
I'm currently having to duplicate the html templates between projects for it to only work in dev, is there a workaround for to get dev to pick up the folder as it would when published?
It should be in the Host project folder along with all the other Website assets. This is the default location .NET Core expects your content resources to be in.
You could register it as an embedded resource or file system mapping, but the natural location is in your Content folder.