cake-build/cake

Newtonsoft.Json.dll not loaded in AppDomain when addins are pinned

開放

#2,698 建立於 2020年1月17日

 (0 則留言) (0 個反應) (1 位負責人)C# (738 個分叉)batch import
BugHelp wantedUp-for-grabs

倉庫指標

星標
 (3,742 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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 in Cake.Issues.Reporting.Generic and this line 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<IIssue>();

    var settings =
        GenericIssueReportFormatSettings
            .FromEmbeddedTemplate(GenericIssueReportTemplate.HtmlDxDataGrid);
    CreateIssueReport(
        issues,
        GenericIssueReportFormat(settings),
        repoRootFolder,
        repoRootFolder.CombineWithFilePath("report.html"));
});

RunTarget("Default");

Output Log

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.

貢獻者指南