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
-
5I 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 content – D Stanley Dec 01 '14 at 19:50
-
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. – atikot Dec 01 '14 at 19:57
-
1i 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 on – DLeh Dec 01 '14 at 20:01
-
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 problem – atikot Dec 01 '14 at 20:07
3 Answers
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

- 3,153
- 5
- 36
- 53
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

- 1,060
- 1
- 20
- 35
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>

- 353
- 2
- 10