Skip to content

Instantly share code, notes, and snippets.

@danpetitt
Last active March 25, 2024 16:17
Show Gist options
  • Save danpetitt/a85d62ee2ba031dbb242da76f9afa460 to your computer and use it in GitHub Desktop.
Save danpetitt/a85d62ee2ba031dbb242da76f9afa460 to your computer and use it in GitHub Desktop.
Nuget Spec for Deploying Windows Redistributable DLLs

Nuget Definitions for Redistributing Windows DLLs for Azure App Service

Copy the following from your C:\Windows\System32 folder into a new folder "x64" alongside the nuspec file:

  • msvcp140.dll
  • vcruntime140.dll
  • vcruntime140_1.dll

Copy the following from your C:\Windows\SysWOW64 folder into a new folder "x86" alongside the nuspec file:

  • msvcp140.dll
  • vcruntime140.dll

Here is the nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>DanPetitt.VC2019Redist</id>
    <version>14.25.28508.5</version>
    <title>VC 2019 Redistributable</title>
    <authors>Dan Petitt</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>VC2019 Redistributable DLLs as they do not exist on App Service</description>
    <summary>VC2019 Redistributable DLL</summary>
    <language>en-GB</language>
    <tags>vc2019 c++ redist redistributable</tags>
  </metadata>
  <files>
    <file src="x64\msvcp140.dll" target="runtimes\win-x64\native\msvcp140.dll" />
    <file src="x64\vcruntime140.dll" target="runtimes\win-x64\native\vcruntime140.dll" />
    <file src="x64\vcruntime140_1.dll" target="runtimes\win-x64\native\vcruntime140_1.dll" />

    <file src="x86\msvcp140.dll" target="runtimes\win-x86\native\msvcp140.dll" />
    <file src="x86\vcruntime140.dll" target="runtimes\win-x86\native\vcruntime140.dll" />

    <file src="DanPetitt.VC2019Redist.targets" target="build\net40\"/>
  </files>
</package>

Here is the DanPetitt.VC2019Redist.targets file referenced in the nuspec:

<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Condition="'$(OS)' != 'Unix' And '$(Platform)' == 'x64'">
      <NativeDLL Include="$(MSBuildThisFileDirectory)\runtimes\win-x64\native\*.dll" />
      <Content Include="@(NativeDLL)">
          <Link>%(FileName)%(Extension)</Link>
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
  </ItemGroup>
  <ItemGroup Condition="'$(OS)' != 'Unix' And '$(Platform)' == 'x86'">
      <NativeDLL Include="$(MSBuildThisFileDirectory)\runtimes\win-x86\native\*.dll" />
      <Content Include="@(NativeDLL)">
          <Link>%(FileName)%(Extension)</Link>
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
  </ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment