visual studio:将某个目录下的项目引用的*.pdb复制到TargetDir。

问题描述 投票:0回答:1

有一些解决方案(业务逻辑等)会将他们的*.dll和*.pdb复制到一些目录中。

  <PropertyGroup>
<PostBuildEvent>copy $(TargetPath) $(DllDir)\*.*

copy $(TargetDir)*.pdb $(SymbolsFolder)\*.pdb </ PostBuildEvent> </ PropertyGroup>

有一些GUI解决方案引用了这些dlls(不是每一个,只是其中的几个)为了更好的调试体验,如果能在编译时或成功构建后,将引用的汇编的*.pdb从$(SymbolsFolder)复制到构建GUI项目的bindebug目录下,那将是非常好的。

在GUI的*.csproj文件中加入类似这样的代码。

  <Target Name="Compile">

<MSBuild Projects="@(Reference)" Targets="Build" >
  copy  $(SymbolsFolder)\'%(Name)'.pdb $(TargetDir)*.pdb
</MSBuild>

这段代码不能用. 你能帮我纠正这个伪代码吗?

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{15E44798-6182-44B0-9302-C96532A334FF}</ProjectGuid>
    <OutputType>library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>GuiControls</RootNamespace>
    <AssemblyName>GuiControls</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <WarningLevel>4</WarningLevel>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
    <UseVSHostingProcess>true</UseVSHostingProcess>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup>
    <SignAssembly>true</SignAssembly>
  </PropertyGroup>
  <PropertyGroup>
    <AssemblyOriginatorKeyFile>test21.snk</AssemblyOriginatorKeyFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_x86|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\Debug_x86\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_x86|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug_x86\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Releasex86|AnyCPU'">
    <OutputPath>bin\Releasex86\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Releasex86|x86'">
    <OutputPath>bin\x86\Releasex86\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Accessibility" />
    <Reference Include="Pr21BusinessObjects5">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Pr21BusinessObjects5.dll</HintPath>
    </Reference>
    <Reference Include="Pr21BusinessObjects5.DataAccess">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Pr21BusinessObjects5.DataAccess.dll</HintPath>
    </Reference>
    <Reference Include="Pr21BusinessObjectsFlat">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Pr21BusinessObjectsFlat.dll</HintPath>
    </Reference>
    <Reference Include="Pr21Common">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Pr21Common.dll</HintPath>
    </Reference>
    <Reference Include="Product21.Datamodel">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Product21.Datamodel.dll</HintPath>
    </Reference>
    <Reference Include="Product21.Factory">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Product21.Factory.dll</HintPath>
    </Reference>
    <Reference Include="Product21.Utilities">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Product21.Utilities.dll</HintPath>
    </Reference>
    <Reference Include="Product21CodingLists">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Product21CodingLists.dll</HintPath>
    </Reference>
    <Reference Include="Pr21Interfaces">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Pr21Interfaces.dll</HintPath>
    </Reference>
    <Reference Include="Pr21UtilsHelpers">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\Pr21UtilsHelpers.dll</HintPath>
    </Reference>
    <Reference Include="BusinessObjects">
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\BusinessObjects.dll</HintPath>
    </Reference>
    <Reference Include="ConfigurationProduct21, Version=1.0.0.0, Culture=neutral, PublicKeyToken=549588756ec70082, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Product21Projects2018\DllsProduct21\ConfigurationProduct21.dll</HintPath>
    </Reference>
    <Reference Include="InfragisticsWPF4.Controls.Charts.XamDataChart.v13.1, Version=13.1.20131.2406, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Infragistics\Infragistics2013\SharedXAML\InfragisticsWPF4.Controls.Charts.XamDataChart.v13.1.dll</HintPath>
    </Reference>
    <Reference Include="InfragisticsWPF4.DataPresenter.v13.1, Version=13.1.20131.2406, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Infragistics\Infragistics2013\WPFOnly\InfragisticsWPF4.DataPresenter.v13.1.dll</HintPath>
    </Reference>
    <Reference Include="InfragisticsWPF4.DataVisualization.v13.1, Version=13.1.20131.2406, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Infragistics\Infragistics2013\SharedXAML\InfragisticsWPF4.DataVisualization.v13.1.dll</HintPath>
    </Reference>
    <Reference Include="InfragisticsWPF4.Editors.v13.1, Version=13.1.20131.2406, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Infragistics\Infragistics2013\WPFOnly\InfragisticsWPF4.Editors.v13.1.dll</HintPath>
    </Reference>
    <Reference Include="InfragisticsWPF4.v13.1, Version=13.1.20131.2406, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Infragistics\Infragistics2013\WPFOnly\InfragisticsWPF4.v13.1.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Expression.Interactions, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Microsoft.Expression.Interactions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
    <Reference Include="Microsoft.Practices.Prism">
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Microsoft.Practices.Prism.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.Prism.Interactivity">
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Microsoft.Practices.Prism.Interactivity.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.Prism.MefExtensions">
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Microsoft.Practices.Prism.MefExtensions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.Prism.UnityExtensions">
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Microsoft.Practices.Prism.UnityExtensions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.ServiceLocation">
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Microsoft.Practices.ServiceLocation.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.Unity">
      <HintPath>..\..\..\Product21Projects2018\DllsExternal\Microsoft.Practices.Unity.dll</HintPath>
    </Reference>
    <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
      <HintPath>..\packages\NLog.4.0.0\lib\net45\NLog.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
    <Reference Include="Prism, Version=7.1.0.431, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
      <HintPath>..\packages\Prism.Core.7.1.0.431\lib\net45\Prism.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="ReachFramework" />
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.IO.Compression" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Printing" />
    <Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Xml" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Xaml">
      <RequiredTargetFramework>4.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="Telerik.Windows.Controls, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Controls.FixedDocumentViewers, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="telerik.windows.controls.fixeddocumentviewersui, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Controls.ImageEditor, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Controls.Input, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Controls.Navigation, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Controls.RibbonView, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Controls.RichTextBoxUI, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Documents, Version=2020.1.218.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Documents.Core, Version=2020.1.212.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="Telerik.Windows.Documents.Fixed, Version=2020.1.212.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL" />
    <Reference Include="TXTextControl, Version=19.0.1200.500, Culture=neutral, PublicKeyToken=6b83fe9a75cfb638, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Program Files\Text Control GmbH\TX Text Control 19.0.NET for WPF\Assembly\TXTextControl.dll</HintPath>
    </Reference>
    <Reference Include="UIAutomationProvider" />
    <Reference Include="UIAutomationTypes" />
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="WindowsFormsIntegration" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Properties\AssemblyInfo.cs">
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <None Include="Product21.snk" />
    <None Include="Pr21p.config" />
    <None Include="packages.config" />
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <AppDesigner Include="Properties\" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <PropertyGroup>
    <PostBuildEvent>copy $(TargetPath) $(Pr21DllDir)\*.*
copy $(TargetName).pdb $(Product21SymbolsFolder)\$(TargetName).pdb
if $(ConfigurationName) == Debug (
copy  $(Product21SymbolsFolder)\Pr21BusinessObjects5.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\Pr21BusinessObjectsFlat.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\Pr21Common.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\Pr21Constants.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\Product21.Datamodel.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\Product21.Factory.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\Pr21Interfaces.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\Pr21Styles.pdb $(TargetDir)\*.*
copy  $(Product21SymbolsFolder)\BusinessObjects.pdb $(TargetDir)\*.*
)</PostBuildEvent>
  </PropertyGroup>
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
visual-studio msbuild
1个回答
1
投票

visual studio: 将项目引用中的*.pdb从某个目录复制到TargetDir。

我认为主要的问题是你没有定义自定义的属性 Pr21DllDirProduct21SymbolsFolder 在您的xxx.csproj文件中,我没有看到这些属性。所以当你执行这些命令时,MSBuild无法识别出 $(Pr21DllDir)$(Product21SymbolsFolder).

解决办法

你可以试试这些。

       <PropertyGroup>
         <Pr21DllDir>C:\xxx\xxxx\xxx(the folder name)</Pr21DllDir>   
        <Product21SymbolsFolder>C:\xxx\xxx\xxx(the folder name)</Product21SymbolsFolder>    
        </PropertyGroup>
 <PropertyGroup>
   <PostBuildEvent>
    copy $(TargetPath) $(Pr21DllDir)\*.*
    copy $(TargetName).pdb $(Product21SymbolsFolder)\$(TargetName).pdb
    if $(ConfigurationName) == Debug (
    copy  $(Product21SymbolsFolder)\Pr21BusinessObjects5.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\Pr21BusinessObjectsFlat.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\Pr21Common.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\Pr21Constants.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\Product21.Datamodel.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\Product21.Factory.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\Pr21Interfaces.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\Pr21Styles.pdb $(TargetDir)\*.*
    copy  $(Product21SymbolsFolder)\BusinessObjects.pdb $(TargetDir)\*.*
    )
     </PostBuildEvent>
  </PropertyGroup>

并确保文件夹存在于你的路径下。由于您没有提供错误信息,如果您有任何其他错误,请与我们分享,我们将尽快帮助您解决。

更新1

尽量用这些节点代替 PostBuildEvent 属性,而这个函数在我这边工作得很好,并且可以匹配参考dll名称在 产品21符号文件夹 文件夹。

你应该删除每一个参考的dll的。Version,CulturePublicKeyTokenxxx.csproj 文件。

如:改变 <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">

<Reference Include="Newtonsoft.Json">.

功能

目标 test 是为了拆分项目引用的所有依赖关系。

目标 test1 中的引用依赖关系相匹配。Product21SymbolsFolder,匹配成功,复制到输出文件夹。

 <PropertyGroup>
    <Pr21DllDir>C:\xxx\xx</Pr21DllDir>
    <Product21SymbolsFolder>C:\xxx\xxx</Product21SymbolsFolder>
  </PropertyGroup>

    <Target Name="test" AfterTargets="Build">
        <PropertyGroup>
            <MoreFile>
                @(Reference)
            </MoreFile>     
        </PropertyGroup>
        <ItemGroup>
            <MoreFilesArray Include="$(MoreFile.Split(';'))" />
        </ItemGroup>        
    </Target>

    <Target Name="test1" AfterTargets="test">
        <Copy SourceFiles="$(TargetPath)" DestinationFolder="$(Pr21DllDir)"></Copy>
        <Copy SourceFiles="$(ProjectDir)$(OutputPath)$(TargetName).pdb" DestinationFolder="$(Product21SymbolsFolder)"></Copy>
        <Copy Condition="'$(ConfigurationName)'=='Debug' and Exists('$(Product21SymbolsFolder)\%(MoreFilesArray.Identity).pdb')" SourceFiles=" $(Product21SymbolsFolder)\%(MoreFilesArray.Identity).pdb" DestinationFolder="$(TargetDir)"></Copy>
    </Target>
© www.soinside.com 2019 - 2024. All rights reserved.