Newtonsoft.Json.dll not loaded in AppDomain when addins are pinned
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 778
- Avg merge
- 3h 37m
- Merged PRs (30d)
- 21
Description
### What You Are Seeing?
Cake.Issues.Reporting.Generic addin expects `Newtonsoft.Json.dll` to be loaded into AppDomain and uses it to compile Razor templates. When all addins used in the script are pinned this is not the case. As soon as at least one addin is not pinned `Newtonsoft.Json.dll` is loaded into the app domain.
The Cake.Issues.Reporting.Generic addin uses RazorEngine compiling a Razor template which uses JSON.NET. For this it looks in the current AppDomain for `Newtonsoft.Json.dll` (see [this line](https://github.com/cake-contrib/Cake.Issues.Reporting.Generic/blob/develop/src/Cake.Issues.Reporting.Generic/RazorEngineReferenceResolver.cs#L32) in Cake.Issues.Reporting.Generic and [this line](https://github.com/Antaris/RazorEngine/blob/aa5dd2661fe040ce39020949ebd33d98a530ebe4/src/source/RazorEngine.Core/Compilation/CompilerServicesUtility.cs#L198) in RazorEngine).
Originally reporting in https://github.com/cake-contrib/Cake.Issues.Reporting.Generic/issues/240
### What is Expected?
`Newtonsoft.Json.dll` should always be loaded into the AppDomain by Cake
### What version of Cake are you using?
Cake 0.35.0 on .NET Framework 4.7.2
### Are you running on a 32 or 64 bit system?
64-Bit
### What environment are you running on? Windows? Linux? Mac?
Windows
### Are you running on a CI Server? If so, which one?
### How Did You Get This To Happen? (Steps to Reproduce)
```
// Fails
#addin Cake.Issues&version=0.8.0
#addin Cake.Issues.Reporting&version=0.8.0
#addin Cake.Issues.Reporting.Generic&version=0.8.1
// Works as soon as one of the lines above is replaced with any of those lines
// #addin Cake.Issues
// #addin nuget:?package=Cake.Issues
// #addin Cake.Issues.Reporting
// #addin nuget:?package=Cake.Issues.Reporting
// #addin Cake.Issues.Reporting.Generic
// #addin nuget:?package=Cake.Issues.Reporting.Generic
Task("Default")
.Does(() =>
{
var repoRootFolder = MakeAbsolute(Directory("./"));
var issues = new List();
var settings =
GenericIssueReportFormatSettings
.FromEmbeddedTemplate(GenericIssueReportTemplate.HtmlDxDataGrid);
CreateIssueReport(
issues,
GenericIssueReportFormat(settings),
repoRootFolder,
repoRootFolder.CombineWithFilePath("report.html"));
});
RunTarget("Default");
```
### Output Log
~~~sh
Preparing to run build script...
Addin compatibility check is disabled
Running build script...
========================================
Default
========================================
Creating report 'C:/temp/3/tools/report.html'
Could not find loaded assembly Newtonsoft.Json.dll.
An error occurred when executing task 'Default'.
Error: One or more errors occurred.
Could not find loaded assembly Newtonsoft.Json.dll.
~~~
Contributor guide
Assessment
This issue has not been assessed yet.