如何在资源中添加程序集?

时间:2018-07-02 08:23:38

标签: c# .net visual-studio deployment

我正在使用ILSpy分析.NET Framework程序集。我注意到一个Resources文件夹,其中包含许多DLL和* .tx文件。当您的VisualStudio项目引用中具有程序集时,这些资源将被复制到输出文件夹。

我需要在自己的程序集中复制此行为,如何在我的VisualStudio项目中以及在哪里添加这些文件?

原始程序集是.NET包装器,资源文件夹中的DLL是不受管理的C / C ++。

谢谢。

enter image description here

1 个答案:

答案 0 :(得分:0)

我们终于解决了这个Visual Studio C ++ / CLI项目及其AssemblyLinkResources部分:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{FF5EF878-3A80-4DD6-B795-8548ED621BC0}</ProjectGuid>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <Keyword>ManagedCProj</Keyword>
    <RootNamespace>CopyModules</RootNamespace>
    <SccProjectName>SAK</SccProjectName>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
    <SccProvider>SAK</SccProvider>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
    <CLRSupport>true</CLRSupport>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
    <LinkKeyFile>..\..\..\Control\Source\Control.snk</LinkKeyFile>
    <TargetName>CopyModules</TargetName>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader>Use</PrecompiledHeader>
    </ClCompile>
    <Link>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <AdditionalDependencies />
      <AssemblyLinkResource>modules\libcrypto.dll;modules\sisl.dll;modules\TD_Alloc_4.3_11.dll;modules\TD_Db_4.3_11.dll;modules\TD_DbRoot4.3_11.dll;modules\TD_DynBlocks_4.3_11.tx</AssemblyLinkResource>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="CopyModules.h" />
    <ClInclude Include="resource.h" />
    <ClInclude Include="Stdafx.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="AssemblyInfo.cpp" />
    <ClCompile Include="CopyModules.cpp" />
    <ClCompile Include="Stdafx.cpp">
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="app.rc" />
  </ItemGroup>
  <ItemGroup>
    <Image Include="app.ico" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>