-
-
Notifications
You must be signed in to change notification settings - Fork 72
Craft your own Microsoft.CobaltCore NuGet package
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
- You can find it in the GAC of the OWA server:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.CobaltCore\
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.
- Download ILSpy
- Open the
Microsoft.CobaltCore.dll
- Right-click the assembly and hit "Save code"
- Open and build the generated solution in Visual Studio
- Fix the errors by decompiling the failing members using dotPeek
- Fix the errors caused by
[Assembly*]
attributes by moving them to .csproj - 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>
- 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".
If your project uses the full .NET Framework (4.0+), this is the way to go.
- Install NuGet Package Explorer
- 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>