microsoft / service-fabric-issues

This repo is for the reporting of issues found with Azure Service Fabric.
168 stars 21 forks source link

System.Fabric (6.1.211-preview) does not have a strong name #481

Closed mkosieradzki closed 7 years ago

mkosieradzki commented 7 years ago

Preview version of packages are causing issues during compilation.

10>CSC : warning CS8002: Referenced assembly 'Microsoft.ServiceFabric.Services, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. 10>CSC : warning CS8002: Referenced assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. 10>CSC : warning CS8002: Referenced assembly 'Microsoft.ServiceFabric.Data.Interfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name.

I have checked for example package: microsoft.servicefabric\6.1.211-preview and ref and runtime version of System.Runtime is not signed, but net45 version is signed. However I am not really convinced it should be net45 and not netstandard2.0... but that's a different issue

The core issue I am investingating is: error CS0012: The type 'ServiceContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. - and my guess this is due to the discrepancy between ref lib and runtime assemblies

elqueffo commented 7 years ago

Having the same issue, on a net461 project.

Error CS0012 The type 'StatefulService' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.ServiceFabric.Services, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Error CS0012 The type 'ServiceInstanceListener' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.ServiceFabric.Services, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

I can't build anything with the preview packages due to this.

hrushib commented 7 years ago

@mkosieradzki, Thanks for reporting this issue.

mkosieradzki commented 7 years ago

I am quite sure that CS0012 is related to the signing issue ;)

pksorensen commented 7 years ago

running into the same with FabActUtil:

2>System.IO.FileLoadException: Could not load file or assembly 'Microsoft.ServiceFabric.Actors, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
2>File name: 'Microsoft.ServiceFabric.Actors, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> System.IO.FileLoadException: A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
2>   at FabActUtil.ToolContext..ctor()
2>   at FabActUtil.Tool.Run(ToolArguments arguments)
2>   at FabActUtil.Program.Main(String[] args)
<Exec Command=".\bin\Debug\net462\win7-x64\FabActUtil.exe /spp:PackageRoot /t:manifest /arp:.\bin\Debug\net462\win7-x64\ /sp:DotNetCoreActorExample /in:.\bin\Debug\net462\win7-x64\DotNetCoreActorExample.exe" />
pksorensen commented 7 years ago

So, from this issue i gather that the libs for netstandard2.0 (located in /ref folder in nuget) are not strong named.

I reverted my projects back to 462, but still my project got the bad dlls above. (easy to see the different in output folder. Microsoft.ServiceFabric.Actor is 452kb for the net452 in nuget and 417kb for the netstandard).

I created a very clean project with the following csproj.

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net462</TargetFramework>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Serilog.Sinks.Trace" Version="2.1.0" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
    <PackageReference Include="Unity" Version="5.0.0-beta" />
    <PackageReference Include="Microsoft.ServiceFabric" Version="6.1.211-preview" />
    <PackageReference Include="Microsoft.ServiceFabric.Data" Version="3.0.211-preview" />
    <PackageReference Include="Microsoft.ServiceFabric.Actors" Version="3.0.211-preview" />
    <PackageReference Include="Microsoft.ServiceFabric.Services" Version="3.0.211-preview" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\..\..\..\..\dev\S-Innovations\S-Innovations.ServiceFabric.Unity\src\S-Innovations.ServiceFabric.Unity\S-Innovations.ServiceFabric.Unity.csproj" />
  </ItemGroup>

</Project>

and build to see that the output uses the 452kb version of Actors.dll.

If I clean the output folder, add <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" /> as a dependency and build again, i now have the bad dll 417kb in my output folder.

I am not clever enough to figure out why dotnet core works like this, but this caused me some issues due them not being strong named.

mkosieradzki commented 7 years ago

@hrushib Not fixed in 3.0.219-preview :-(

mkosieradzki commented 7 years ago

OK. Some more info on this issue. This nuget package is broken two-fold.

  1. If you reference it from net461 -> it always fails (different way depending on whether it is signed or not).
  2. However if you reference it from netcoreapp2.0 you can make it work by disabling assembly signing..

So basically there are three additional scenarios to test:

  1. Referencing from net461 signed

  2. Referencing from net461 not-signed

  3. Referencing from netcoreapp2.0 signed

  4. Referencing from netcoreapp2.0 not-signed - basically works but it fails due to probable bug in satellite assembly resolution #563

raunakpandya commented 7 years ago

Yes, the fix is still not out yet for this one. Will confirm here once we update the SDK.

PepijnGramberg commented 7 years ago

@raunakpandya This issue is caused us to change our test projects to netcoreapps, which means our codecoverage tooling is not able to work, as they are still working on that feature for netcore. Could you give an indication in which SDK this problem will be addressed and when this SDK will become available?

raunakpandya commented 7 years ago

The fix for this should be out very soon in the next SDK update, which is in the process of rollout. I didn't quite understand what do you mean by having to update test projects to netcoreapps because of this issue. Can you elaborate there?

PepijnGramberg commented 7 years ago

During compilation of the net47 testproject, the System.Fabric dll from netstandard/ref gets used. However the dll in the output folder was the net45 version. This caused exceptions of not being able to find the assembly during the tests.

Making the test project a netcoreapp project, it is compiled and uses the netstandard System.Fabric assembly and works correctly. But as stated before our tooling is not able to do code coverage for netcore test dlls yet.

hrushib commented 7 years ago

@PepijnGramberg, I didn't get what you mean by below statement

However the dll in the output folder was the net45 version.

Some follow-up questions below.

  1. How are you building and publishing this project?
  2. Is ServiceFabric runtime installed on the machine where this project is built?
  3. Is it possible for you to create and share minimal project where this issue reproduces?
PepijnGramberg commented 7 years ago
  1. main project (netstandard) with a reference to Service Fabric. Test project (net47) with a reference to the main project. In the test bin folder I find the net45 System.Fabric assembly (publicKeyToken 31bf3856ad364e35).

During testing when loading the main project assembly it starts looking for the netstandard System.Fabric Assembly (PublicKeyToken NULL) and cannot find it.

Building is done in VS 15.4.2

  1. Service fabric is installed on the machine. (The normal app is running as that is already a netcoreapp)
  2. Will see if I have the time.
pksorensen commented 7 years ago

@raunakpandya - i see that the next SDK has been released.

But i dont see any new nuget preview packages? Does this mean that the issue with not signed dll was not in the nugets? or is there coming updated nuget packages also?

mkosieradzki commented 7 years ago

@pksorensen According to the release notes there are no changes the in .NET SDKs and Preview SDKs :-(

mkosieradzki commented 7 years ago

I have checked some random nuget packages and it seems 6.1.232-preview are finally signed! I am going to check today!

pksorensen commented 7 years ago

Cool, i also managed to get netcoreapp2.0 service fabric apps running with netstandard2.0 libraries.

hrushib commented 7 years ago

@pksorensen - Great to know that you were able to get netcoreapp2.0 working with this SDK.

@mkosieradzki - These packages are released as part of Service Fabric 6.0 CU2, and should fix compilation issue you were facing.

@PepijnGramberg - Please update your project to use nuget package version 6.1.232-preview, this will resolve issue you were facing (PublicKeyToken NULL).

PepijnGramberg commented 7 years ago

@hrushib Thanks that fixed it