how to set all projects in solution to copy local false
Asked Answered
B

3

2

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

Brocket answered 1/12, 2014 at 19:48 Comment(4)
I don't know of a tool that does that - but a .csproj file is just XML - you could build a little utility to change the XML contentAuberbach
would be nice if there was something ready but guess i'll take the time to make one, could be nice just to add it to pre-build event and all set.Brocket
i imagine you'll encounter errors when you set all of them to copy local false. just be ready to debug this, which, if you have 200 projects, sounds like it'd be more of a pain to go back and find out which ones you DO need copy local onDendro
most of it already set to copy local false, some times references are missed and then it's more of a problem to find the rogue projects that doesn't have copy local false.. so no, should not be a problemBrocket
L
1

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> 
Lineate answered 1/12, 2014 at 21:46 Comment(0)
V
3

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:

screenshot

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

IDE: VS2013 french

Vinegarish answered 1/12, 2014 at 20:19 Comment(0)
T
2

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://mcmap.net/q/399858/-set-quot-copy-local-quot-to-false-by-default

Typify answered 14/6, 2018 at 13:54 Comment(0)
L
1

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> 
Lineate answered 1/12, 2014 at 21:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.