/LinkResource in Visual Studio 2010

后端 未结 1 1280
小鲜肉
小鲜肉 2020-12-03 22:05

/linkresource is a csc option that allows to link an assembly to its unmanaged dependencies. When the managed assembly is added to the GAC, the dependencies are placed in th

1条回答
  •  情深已故
    2020-12-03 22:55

    I managed to get this to work in vs2010 albeit with warnings.

    1) Override CoreCompile to add LinkResources

    2) Add a target to get the equivalent of Copy Local on anything added as

    3) If the project containing the native libraries/file only contains those files, add a type/interface. Use this type in the project using the references. I.e. the project where you use DllImport. The prevents the compiler optimising out the project dependency.

    4) Tack on Alex Yakunin's trick to copy project dependencies.

    This pulls all the dependencies into my $(TargetDir) ready for debugging.

    In the project files I import the magic after the regular targets files ala

      
      
    

    And I have a CopyDependencies.targets as follows:

    
    
    
      
        
        
          $(NoWarn);1701;1702
        
    
        
          
          $(MsBuildToolsPath)
        
    
        
          
            
          
        
    
        
          
          $(AppConfig)
        
    
        
        
    
        
          <_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
        
    
        
    
      
    
    
      
        true
      
    
      
        true
        true
        true
      
    
    
      
        
        
          
        
        
      
    
    
    
    
        
          
        
        
      
    
      
    
        
        
    
        
        
            
        
    
        
            
          
    
        
            
        
    
    
        
        
                      
    
            
        
    
      
    
      
    
      
        
          $(CoreBuildDependsOn);
          CopyDependencies;
          CopyLinkedResources
        
      
    
    

    0 讨论(0)
提交回复
热议问题