-
-
Save inascf/aa91a9c228796dee80216cda2f1a40bd to your computer and use it in GitHub Desktop.
Run Office 2019 in Windows Full Container (19H1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
pushd "%~dp0" | |
docker build -t o365full:latest . | |
:exit | |
popd | |
@echo on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Configuration> | |
<Add OfficeClientEdition="32" Channel="PerpetualVL2019"> | |
<Product ID="ProPlus2019Volume"> | |
<Language ID="ko-kr" /> | |
</Product> | |
</Add> | |
<Display Level="None" AcceptEULA="TRUE" /> | |
<Property Name="AUTOACTIVATE" Value="1"/> | |
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mcr.microsoft.com/windows:1903 AS build | |
WORKDIR C:\\odtsetup | |
ADD https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_11617-33601.exe odtsetup.exe | |
RUN odtsetup.exe /quiet /norestart /extract:C:\\odtsetup | |
FROM mcr.microsoft.com/windows:1903 AS download | |
WORKDIR C:\\odtsetup | |
COPY --from=build C:\\odtsetup\\setup.exe . | |
ADD config.xml . | |
RUN setup.exe /download C:\\odtsetup\\config.xml | |
FROM mcr.microsoft.com/windows:1903 | |
MAINTAINER rkttu | |
WORKDIR C:\\odtsetup | |
COPY --from=build C:\\odtsetup\\setup.exe . | |
COPY --from=download C:\\odtsetup\\Office . | |
ADD config.xml . | |
RUN setup.exe /configure C:\\odtsetup\\config.xml | |
WORKDIR / | |
RUN rmdir /s /q C:\\odtsetup | |
# https://stackoverflow.com/questions/10837437/interop-word-documents-open-is-null | |
RUN powershell -Command new-object -comobject word.application | |
RUN mkdir C:\\Windows\\SysWOW64\\config\\systemprofile\\Desktop | |
VOLUME C:\\data | |
ADD sample . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires office.dll and word interop pia.dll from GAC | |
using Microsoft.Office.Interop.Word; | |
using System; | |
using System.IO; | |
using System.Linq; | |
namespace OfficePIATest | |
{ | |
internal static class Program | |
{ | |
[STAThread] | |
public static void Main(string[] args) | |
{ | |
var input = args.ElementAtOrDefault(0) ?? string.Empty; | |
var output = args.ElementAtOrDefault(1) ?? string.Empty; | |
if (!File.Exists(input)) | |
{ | |
Console.Error.WriteLine("Cannot open the file `{0}`.", input); | |
Environment.Exit(1); | |
return; | |
} | |
if (string.IsNullOrWhiteSpace(output)) | |
{ | |
Console.Error.WriteLine("Invalid output path."); | |
Environment.Exit(2); | |
return; | |
} | |
var outputDir = Path.GetDirectoryName(output); | |
if (!Directory.Exists(outputDir)) | |
Directory.CreateDirectory(outputDir); | |
var wordApp = new Application(); | |
Console.Out.WriteLine("word app initialized."); | |
Document wordDocument = null; | |
var t = new System.Threading.Tasks.Task(() => wordDocument = wordApp.Documents.Open(input)); | |
t.Start(); | |
t.Wait(); | |
if (wordDocument == null) | |
{ | |
Console.Error.WriteLine("Word document is null reference."); | |
Environment.Exit(3); | |
return; | |
} | |
else | |
Console.Out.WriteLine("Word document opened."); | |
wordDocument.ExportAsFixedFormat(output, WdExportFormat.wdExportFormatPDF); | |
Console.Out.WriteLine("Export performed."); | |
wordDocument.Close(WdSaveOptions.wdDoNotSaveChanges, | |
WdOriginalFormat.wdOriginalDocumentFormat, | |
false); //Close document | |
Console.Write("Closing document"); | |
wordApp.Quit(); //Important: When you forget this Word keeps running in the background | |
Console.Out.WriteLine("Quitting word app."); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
pushd "%~dp0" | |
docker run -v %cd%\data:c:\data --rm -it --name=o365fulltest o365full:latest cmd | |
:exit | |
popd | |
@echo on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment