I have multi-target NUnit Test Project (Project1.Test) (net45;netcoreapp2.0)
The project reference project1 which is also multi-target (net45;netcoreapp2.0)
The libraries used:
<ItemGroup>
<PackageReference Include="nunit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
</ItemGroup>
Project1 have a static class StartUp with a property that use CompanyAssemplyAttribute :
public class StartUp
{
private static string CopyRight= CopyrightInfo. Default; // it retrieve the assemplyAttribute AssemplyCompany
....
}
The test method
public class StartUpTest
{
[Test]
public void Test1()
{
var copyright=StartUp.CopyRight;
Assert.AreEqual(copyRight,"xyz Company");
}
}
I use dotnet CLI command dotnet test.
I run for both frameworks the following command:
For net45 framework: Test Run Successful
For netcoreapp2.0: Test Fail with an exception:
Failed DefaultSettingTest()
Error Message:
System.AggregateException : One or more errors occurred. (The type initializerfor 'project1.StartUp' threw an exception.)
----> System.TypeInitializationException : The type initializer for 'project1.StartUp' threw an exception.
----> System.ArgumentException : author
Stack Trace:
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
..... other messages-----
--- End of stack trace from previous location where exception was thrown ---
at Project1.StartUp.RunOptionsAsync(String[] args) in F:\project1\Program.cs:line 103
--ArgumentException
at CommandLine.Text.CopyrightInfo..ctor(Boolean isSymbolUpper, String author, Int32[] copyrightYears)
at CommandLine.Text.CopyrightInfo.get_Default()
All assemply attributes are defined in the project properties
The same result for netcoreapp2.1
It seems that netcoreapp2.0 can't initialize the CompanyAssemplyAttribute.
What i missed for netcoreapp2.0 to run successful like net45 when accessing AssemplyAttributes.?
Repro project
I have multi-target NUnit Test Project (Project1.Test) (net45;netcoreapp2.0)
The project reference project1 which is also multi-target (net45;netcoreapp2.0)
The libraries used:
Project1 have a static class StartUp with a property that use CompanyAssemplyAttribute :
The test method
I use dotnet CLI command
dotnet test.I run for both frameworks the following command:
For net45 framework: Test Run Successful
For netcoreapp2.0: Test Fail with an exception:
The same result for netcoreapp2.1
It seems that netcoreapp2.0 can't initialize the CompanyAssemplyAttribute.
What i missed for netcoreapp2.0 to run successful like net45 when accessing AssemplyAttributes.?
Repro project