Referenced DLL not being copied to referencing project

前端 未结 3 403
灰色年华
灰色年华 2020-12-29 15:45

This question might have been asked multiple times and maybe I\'m just bad at using the search functions here aswell as google but I\'ve not found an answer to this question

3条回答
  •  一整个雨季
    2020-12-29 16:20

    This question has been answered already but I figured I'll include a generic fail-safe method for copying all indirect references into your projects' output directories.

    1. Set Copy Local to true for all references you want to be included with your output.
    2. Save the copy indirect dependencies code (see below) into a file with the name CopyIndirectDependencies.targets and place the targets file in your project directory.
    3. Edit your .csproj or .vbproj to include an import to the .targets file you added. See example below.
    4. Build your project and you should have secondary dependencies automatically copied to the build output.

    CopyIndirectDependencies.targets File Content

    
    
      
        true
        false
        false
      
    
    
      
    
      
        
          
        
        
      
    
      
    
        
        
    
        
        
          
        
        
          
        
        
          
        
    
        
        
          
        
    
        
        
          
        
    
        
        
          
        
    
      
    
    
      
    
      
        
          $(CoreBuildDependsOn);
          CopyIndirectDependencies
        
      
    
    

    Sample project with import

    
    
    
      ...
    
      
       
    
      ...
    
    
    

    Source: http://blog.alexyakunin.com/2009/09/making-msbuild-visual-studio-to.html

提交回复
热议问题