Skip to content

Craft your own Microsoft.CobaltCore NuGet package

Petr Švihlík edited this page Oct 17, 2019 · 4 revisions

There might be times where you need to reference the Microsoft.CobaltCore assembly. However, the library is not open-source. It's a part of the Office Online Server, Office Web Apps, and Sharepoint whose license terms don't allow its distribution. However, you can, for testing and research purposes, create your own Microsoft.CobaltCore NuGet package.

⚠️ Please always make sure your OWA/OOS server and user connecting to it have valid licenses before you start using it.

Depending on what you need to achieve, there are several approaches you can take. But the first step is always to locate Microsoft.CobaltCore.dll

  1. You can find it in the GAC of the OWA server: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.CobaltCore\

Port Microsoft.CobaltCore to .NET Standard / .NET Core

If your project is targeting .NET Core, you need to port the library. The porting is achieved by decompiling the library. The best result can be achieved by first using the ILSpy utility and then fixing the problematic parts with dotPeek. I also tried RedGate's .NET Reflector, Telerik's JustDecompile, and dnSpy but it didn't work out well.

  1. Download ILSpy
  2. Open the Microsoft.CobaltCore.dll
  3. Right-click the assembly and hit "Save code"
  4. Open and build the generated solution in Visual Studio
  5. Fix the errors by decompiling the failing members using dotPeek
  6. Fix the errors caused by [Assembly*] attributes by moving them to .csproj
  7. Add references to System.Reflection.Emit.* packages. This is the resulting Microsoft.CobaltCore.csproj file:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <Company>Microsoft Corporation</Company>
    <Product>Microsoft Office 2013</Product>
    <FileVersion>15.0.4557.1000</FileVersion>
    <Title>Microsoft Office 2013 component</Title>
    <AssemblyTitle>Microsoft Office 2013 component</AssemblyTitle>
    <AssemblyVersion>15.0.0.0</AssemblyVersion>
    <Version>15.0.0.0</Version>
    <Description>Microsoft Office 2013 component</Description>
    <Copyright>© 2012 Microsoft Corporation.  All rights reserved.</Copyright>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.6.0" />
    <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.6.0" />
  </ItemGroup>

</Project>
  1. Once all errors are fixed, you can create a NuGet package by calling dotnet pack or in Visual Studio by right-clicking the project and hitting "Pack".

Pack the Microsoft.CobaltCore.dll targeting .NET Framework v4.0.30319 in a NuGet package

If your project uses the full .NET Framework (4.0+), this is the way to go.

  1. Install NuGet Package Explorer
  2. Use the following Microsoft.CobaltCore.15.0.4557.1000.nuspec file to create a new package
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
        <id>Microsoft.CobaltCore</id>
        <version>15.0.4557.1000</version>
        <title>Microsoft.CobaltCore</title>
        <authors>Microsoft</authors>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>Implementation of MS-FSSHTTP. Required for a full implementation of MS-WOPI.</description>
        <copyright>Copyright © Microsoft Corporation</copyright>
    </metadata>
    <files>
        <file src="lib\net46\Microsoft.CobaltCore.dll" target="lib\net46\Microsoft.CobaltCore.dll" />
    </files>
</package>