Copy to Output Directory copies folder structure but only want to copy files

后端 未结 8 1904
谎友^
谎友^ 2020-11-27 12:05

I have a VS2008 I want to copy certain files from a directory into my /bin/ folder. I have set the files (located in /common/browserhawk/) to \"Co

8条回答
  •  渐次进展
    2020-11-27 12:39

    I have used this in VS2010, VS2015, VS2017, and VS2019. I prefer this solution because:

    1. The XML is reusable in any project
    2. The "RootContent" is chosen as a Build Action in the Visual Studio UI, just like any other "Content"
    3. The "CopyToOutputDirectory" is obeyed, just as you would expect
    4. The RootContent is added to the project's output: gets carried through Project-References, obeys "Clean", etc.
    5. The RootContent can be specified with a wildcard, preserving the recursive folder structure:
    
      Always
    
    

    Toward the beginning of project file:

      
        
          
          True
        
      
    

    Borrowed From This Answer

    After the Microsoft .targets Import:

      
        
          $(AssignTargetPathsDependsOn);
          IncludeRootContentAsContent;
        
      
      
        
          
        
      
    

    Borrowed From This Answer

提交回复
热议问题