Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pascalberger opened this issue Jan 17, 2020 · 0 comments
Open

Comments

@pascalberger
Copy link
Member

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 cake-contrib/Cake.Issues.Reporting.Generic#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.
@bjorkstromm bjorkstromm self-assigned this Jan 17, 2020
@pascalberger pascalberger changed the title Newtonsoft.Json.dll not loaded in AppDomain when pinging addins Newtonsoft.Json.dll not loaded in AppDomain when addins are pinned Oct 16, 2020
@augustoproiete augustoproiete added this to the v1.x Next Candidate milestone Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants