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

Flush() crashes in published release with the build property PublishSingleFile set to true #191

Open
adelama opened this issue Oct 5, 2023 · 0 comments

Comments

@adelama
Copy link

adelama commented Oct 5, 2023

Hey there,

I have an issue when running the build with PublishSingleFile set to true,
when I try to run that build the RazorEngine throws this exception,

Unhandled exception. System.ArgumentException: The value cannot be an empty string. (Parameter 'path')
   at System.ArgumentException.ThrowNullOrEmptyException(String argument, String paramName)
   at System.IO.Strategies.FileStreamHelpers.ValidateArguments(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.IO.File.OpenRead(String path)
   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
   at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
   at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.SelectMetadataReference.Visit(String file)
   at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.SelectMetadataReference.Visit(Assembly assembly)
   at RazorEngine.Compilation.ReferenceResolver.CompilerReference.DirectAssemblyReference.Visit[T](ICompilerReferenceVisitor`1 visitor)
   at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.<>c.<GetMetadataReferences>b__8_0(CompilerReference reference)
   at System.Linq.Enumerable.SelectListIterator`2.ToArray()
   at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.GetMetadataReferences(IEnumerable`1 references)
   at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.CompileType(TypeContext context)
   at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
   at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at AventStack.ExtentReports.Reporter.ExtentSparkReporter.OnNext(ReportEntity value)
   at System.Reactive.Subjects.Subject`1.OnNext(T value)
   at AventStack.ExtentReports.Core.ReactiveSubject.Flush()
   at AventStack.ExtentReports.Core.AbstractProcessor.OnFlush()
   at AventStack.ExtentReports.ExtentReports.Flush()
   at Program.<Main>$(String[] args) in C:\Users\Working Adel\Projects\ExtentTest\ExtentTest\Program.cs:line 11

It works when the build property PublishSingleFile is set to false but with true one that will happened.

My program.cs code:

using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports;
using AventStack.ExtentReports.Model;

Console.WriteLine("Hello, World!");
var extent = new ExtentReports();
var spark = new ExtentSparkReporter("report.html");
extent.AttachReporter(spark);
extent.CreateTest("TESTTTTTT");
extent.Flush();

My project .csproj which cause exception:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishSingleFile>true</PublishSingleFile>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ExtentReports" Version="5.0.0" />
  </ItemGroup>

</Project>

Publish command:

dotnet publish -c release -o ./bin/win -r win-x64 /p:SelfContained=true

with these properties after publishing the code and running the exe in the path ./bin/win, it will throw the exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant