简体   繁体   中英

how to set all projects in solution to copy local false

is there a quick way to mark all the solution projects references as Copy local false? is there some tool that does that? it's pretty messy to mark about 200 projects manually

I have a tricky way to do it, but it is always manually

Suppose you have two projects

Pull all your references, press shift and select your first reference then keep holding shift and select the last reference of your first project

Release the shift button, press ctrl button and select you first reference of your second project, then you press ctrl and shift button at the same time and select your last reference of your second project

It should be like this:

屏幕截图

Finally you can set Copy local property to false to all your selected references

IDE: VS2013 french

You could use xsl to transform the project file to add False (this is what copy local false does)

Here's an example xslt file

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cs="http://schemas.microsoft.com/developer/msbuild/2003"
exclude-result-prefixes="cs"> 

    <xsl:output method="xml" indent="yes" />
    <xsl:strip-space elements="*"/>

    <xsl:template match="*"> 
    <xsl:copy> 
        <xsl:apply-templates select="@*|*|text()|node()"/> 
    </xsl:copy> 
    </xsl:template> 

    <xsl:template match="cs:Project/cs:ItemGroup/cs:Reference"> 
        <xsl:copy>
      <xsl:apply-templates select="@* | node()" />
          <xsl:if test="not(./cs:Private)">
            <Private>False</Private>
          </xsl:if>

    </xsl:copy>
    </xsl:template> 

    <xsl:template match="@*| text() | node()"> 
        <xsl:copy>
             <xsl:apply-templates select="@* | node()" />
        </xsl:copy>
    </xsl:template>     
</xsl:stylesheet> 

Yes, there is a realy easy and quick way, starting with msbuild v 15. You can copy a single file called Directory.Build.props in the root folder that contains your source:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
  <Reference>
    <Private>False</Private>
  </Reference>
</ItemDefinitionGroup>
</Project>

Nothing more to do! More info see https://stackoverflow.com/a/50755479/1196586

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM