Search code examples
c#.netcopy-local

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


Solution

  • 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>