Force Microsoft.Build.Tasks.CodeAnalysis into the VSIX
Force Microsoft.Build.Tasks.CodeAnalysis into the VSIX

When we build VisualStudioSetup.csproj, we include a bunch of assemblies from
other projects into the VSIX. This is done through ProjectReferences to the
other projects that produce each binary. It turns out this worked via some more
magic than we expected: when we had a ProjectReference, we typically had the
following metadata:

    <ProjectReference Include="..\..\Compilers\Core\Portable\CodeAnalysis.csproj">
      <Project>{1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}</Project>
      <Name>CodeAnalysis</Name>
      <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX>
    </ProjectReference>

When the VSIX targets run, they would collect all the files that need to be put
into the VSIX. When it would encounter this ProjectReference, it would actually
try to include the output twice. One copy (call it Copy A) would come from the
Binaries folder simply by virtue that the binary was a reference from the
VisualStudioSetup project and must be copied local. The other copy (Copy B) was
coming from the obj directory, because the VSIX targets see us specifying the
BuiltProject- OutputGroup and that output group's items point to obj. (There is
metadata that points to the Binaries folder but that is getting ignored by the
VSIX targets.) The VSIX packaging task would realize we were adding two copies
of a file, it'd arbitrarily pick the first one, which happened to be the one in
the Binaries folder.

This magic blows up in one very special case. If the project's binary happens to
be also found in the GAC, the default behavior of MSBuild is to no longer count
that binary as CopyLocal. Thus, when the VSIX tried to include a binary that was
in the GAC (in this case, Microsoft.Build.Tasks.CodeAnalysis.dll), it'd decide
it didn't need to copy it local at all. Thus Copy A in the earlier description
didn't exist, and so the VSIX packager would fall back to using Copy B, the copy
of the assembly from the obj folder. When we're doing a signed build, Copy A and
Copy B are actually different -- one is signed, one isn't, and so a lack of Copy
A being given to the VSIX packager meant that we'd end up including unsigned
assemblies in our (supposedly) fully signed VSIX.

The "fun" part is during non-signed builds Copy A is included, since the
locally-built binary (with version 42.42.42.42) isn't in the GAC. Thus if you
try to reproduce the strange MSBuild behavior on a regular build you don't see
it and you don't understand why.

There are two quick fixes:

1. Un-GAC Microsoft.Build.Tasks.CodeAnalysis on any machines that need to do a
   proper signed build.
2. Force the DLL to be copied local. We take this approach since it's best to
   not be subject to the whims of the GAC if we can be.

Long term, we probably should fix the VSIX targets to never look in the obj
folder. They found the obj folder by looking at the items from the
BuiltProjectOutputGroup, but didn't look at the appropriate metadata that would
have let it realize it should really copy from Binaries. This Copy A vs. Copy B
fight happens with any VSIX project, and it'd be best to avoid that.

chenxizhang/roslyn,MihaMarkic/roslyn-prank,sharwell/roslyn,tsdl2013/roslyn,balajikris/roslyn,lisong521/roslyn,jeffanders/roslyn,jasonmalinowski/roslyn,genlu/roslyn,VitalyTVA/roslyn,basoundr/roslyn,budcribar/roslyn,garryforreg/roslyn,shyamnamboodiripad/roslyn,cston/roslyn,oocx/roslyn,VSadov/roslyn,taylorjonl/roslyn,evilc0des/roslyn,jkotas/roslyn,poizan42/roslyn,KevinRansom/roslyn,ljw1004/roslyn,ericfe-ms/roslyn,vcsjones/roslyn,OmniSharp/roslyn,kienct89/roslyn,AlekseyTs/roslyn,AArnott/roslyn,Pvlerick/roslyn,KamalRathnayake/roslyn,sharadagrawal/TestProject2,kuhlenh/roslyn,jeremymeng/roslyn,reaction1989/roslyn,jhendrixMSFT/roslyn,ilyes14/roslyn,dotnet/roslyn,stebet/roslyn,AlexisArce/roslyn,jhendrixMSFT/roslyn,xasx/roslyn,zmaruo/roslyn,3F/roslyn,lisong521/roslyn,KashishArora/Roslyn,russpowers/roslyn,taylorjonl/roslyn,oberxon/roslyn,jmarolf/roslyn,TyOverby/roslyn,srivatsn/roslyn,Inverness/roslyn,yjfxfjch/roslyn,magicbing/roslyn,oberxon/roslyn,pdelvo/roslyn,Shiney/roslyn,bbarry/roslyn,aanshibudhiraja/Roslyn,sharwell/roslyn,tsdl2013/roslyn,diryboy/roslyn,bbarry/roslyn,jrharmon/roslyn,ErikSchierboom/roslyn,akrisiun/roslyn,genlu/roslyn,zmaruo/roslyn,pdelvo/roslyn,dpoeschl/roslyn,rgani/roslyn,a-ctor/roslyn,MihaMarkic/roslyn-prank,aanshibudhiraja/Roslyn,cston/roslyn,JakeGinnivan/roslyn,JakeGinnivan/roslyn,rchande/roslyn,nagyistoce/roslyn,cybernet14/roslyn,managed-commons/roslyn,jkotas/roslyn,jamesqo/roslyn,jaredpar/roslyn,managed-commons/roslyn,jamesqo/roslyn,jhendrixMSFT/roslyn,khellang/roslyn,nemec/roslyn,DustinCampbell/roslyn,yeaicc/roslyn,Shiney/roslyn,MattWindsor91/roslyn,KirillOsenkov/roslyn,natidea/roslyn,diryboy/roslyn,DustinCampbell/roslyn,supriyantomaftuh/roslyn,EricArndt/roslyn,leppie/roslyn,pjmagee/roslyn,aelij/roslyn,MihaMarkic/roslyn-prank,jroggeman/roslyn,garryforreg/roslyn,dpoeschl/roslyn,HellBrick/roslyn,moozzyk/roslyn,jaredpar/roslyn,jbhensley/roslyn,magicbing/roslyn,CaptainHayashi/roslyn,HellBrick/roslyn,KashishArora/Roslyn,droyad/roslyn,evilc0des/roslyn,kienct89/roslyn,AdamSpeight2008/roslyn-AdamSpeight2008,paulvanbrenk/roslyn,wvdd007/roslyn,mgoertz-msft/roslyn,jkotas/roslyn,bkoelman/roslyn,stephentoub/roslyn,physhi/roslyn,KiloBravoLima/roslyn,sharadagrawal/TestProject2,ValentinRueda/roslyn,AdamSpeight2008/roslyn-AdamSpeight2008,weltkante/roslyn,KiloBravoLima/roslyn,zmaruo/roslyn,OmniSharp/roslyn,xoofx/roslyn,CyrusNajmabadi/roslyn,ErikSchierboom/roslyn,RipCurrent/roslyn,MichalStrehovsky/roslyn,Inverness/roslyn,ljw1004/roslyn,mirhagk/roslyn,davkean/roslyn,3F/roslyn,mseamari/Stuff,Shiney/roslyn,vslsnap/roslyn,RipCurrent/roslyn,bkoelman/roslyn,VSadov/roslyn,krishnarajbb/roslyn,tvand7093/roslyn,stjeong/roslyn,kelltrick/roslyn,jaredpar/roslyn,TyOverby/roslyn,dotnet/roslyn,dpoeschl/roslyn,Giten2004/roslyn,tmeschter/roslyn,AlekseyTs/roslyn,yjfxfjch/roslyn,rgani/roslyn,cston/roslyn,stjeong/roslyn,devharis/roslyn,AArnott/roslyn,mattscheffer/roslyn,akrisiun/roslyn,thomaslevesque/roslyn,AmadeusW/roslyn,russpowers/roslyn,Giftednewt/roslyn,v-codeel/roslyn,3F/roslyn,lorcanmooney/roslyn,khyperia/roslyn,Giten2004/roslyn,leppie/roslyn,stebet/roslyn,VShangxiao/roslyn,droyad/roslyn,xasx/roslyn,swaroop-sridhar/roslyn,ValentinRueda/roslyn,michalhosala/roslyn,doconnell565/roslyn,doconnell565/roslyn,ahmedshuhel/roslyn,mgoertz-msft/roslyn,stephentoub/roslyn,TyOverby/roslyn,hanu412/roslyn,pdelvo/roslyn,YOTOV-LIMITED/roslyn,VPashkov/roslyn,chenxizhang/roslyn,DanielRosenwasser/roslyn,panopticoncentral/roslyn,mavasani/roslyn,VShangxiao/roslyn,jeffanders/roslyn,CyrusNajmabadi/roslyn,tvand7093/roslyn,mattscheffer/roslyn,jcouv/roslyn,physhi/roslyn,EricArndt/roslyn,KevinRansom/roslyn,physhi/roslyn,KamalRathnayake/roslyn,nguerrera/roslyn,BugraC/roslyn,DinoV/roslyn,lisong521/roslyn,jeremymeng/roslyn,sharadagrawal/Roslyn,jcouv/roslyn,wvdd007/roslyn,huoxudong125/roslyn,paulvanbrenk/roslyn,garryforreg/roslyn,danielcweber/roslyn,AlexisArce/roslyn,Maxwe11/roslyn,Giten2004/roslyn,kuhlenh/roslyn,Giftednewt/roslyn,bkoelman/roslyn,MattWindsor91/roslyn,robinsedlaczek/roslyn,BugraC/roslyn,Pvlerick/roslyn,jasonmalinowski/roslyn,krishnarajbb/roslyn,budcribar/roslyn,kuhlenh/roslyn,antiufo/roslyn,DustinCampbell/roslyn,mirhagk/roslyn,zooba/roslyn,MichalStrehovsky/roslyn,natidea/roslyn,stebet/roslyn,yeaicc/roslyn,Maxwe11/roslyn,tang7526/roslyn,KirillOsenkov/roslyn,CaptainHayashi/roslyn,aelij/roslyn,KevinH-MS/roslyn,Giftednewt/roslyn,managed-commons/roslyn,jbhensley/roslyn,MatthieuMEZIL/roslyn,dotnet/roslyn,reaction1989/roslyn,oocx/roslyn,tannergooding/roslyn,ValentinRueda/roslyn,grianggrai/roslyn,tvand7093/roslyn,orthoxerox/roslyn,MatthieuMEZIL/roslyn,agocke/roslyn,moozzyk/roslyn,robinsedlaczek/roslyn,grianggrai/roslyn,sharadagrawal/Roslyn,eriawan/roslyn,antiufo/roslyn,MattWindsor91/roslyn,AnthonyDGreen/roslyn,MavenRain/roslyn,zooba/roslyn,SeriaWei/roslyn,srivatsn/roslyn,sharadagrawal/Roslyn,mattwar/roslyn,DinoV/roslyn,BugraC/roslyn,GuilhermeSa/roslyn,jrharmon/roslyn,enginekit/roslyn,mgoertz-msft/roslyn,Hosch250/roslyn,antiufo/roslyn,thomaslevesque/roslyn,magicbing/roslyn,CyrusNajmabadi/roslyn,huoxudong125/roslyn,nagyistoce/roslyn,orthoxerox/roslyn,khyperia/roslyn,mattwar/roslyn,davkean/roslyn,AnthonyDGreen/roslyn,tmat/roslyn,tannergooding/roslyn,gafter/roslyn,shyamnamboodiripad/roslyn,mavasani/roslyn,nemec/roslyn,kienct89/roslyn,AmadeusW/roslyn,brettfo/roslyn,xoofx/roslyn,yjfxfjch/roslyn,MavenRain/roslyn,tang7526/roslyn,tmat/roslyn,rchande/roslyn,vcsjones/roslyn,sharadagrawal/TestProject2,mattscheffer/roslyn,krishnarajbb/roslyn,gafter/roslyn,abock/roslyn,antonssonj/roslyn,DanielRosenwasser/roslyn,amcasey/roslyn,yeaicc/roslyn,KevinH-MS/roslyn,sharwell/roslyn,stephentoub/roslyn,jasonmalinowski/roslyn,evilc0des/roslyn,KashishArora/Roslyn,oberxon/roslyn,heejaechang/roslyn,KamalRathnayake/roslyn,VShangxiao/roslyn,kelltrick/roslyn,jonatassaraiva/roslyn,poizan42/roslyn,chenxizhang/roslyn,heejaechang/roslyn,rchande/roslyn,mmitche/roslyn,eriawan/roslyn,VitalyTVA/roslyn,weltkante/roslyn,jonatassaraiva/roslyn,pjmagee/roslyn,aanshibudhiraja/Roslyn,thomaslevesque/roslyn,bartdesmet/roslyn,amcasey/roslyn,robinsedlaczek/roslyn,VPashkov/roslyn,jonatassaraiva/roslyn,antonssonj/roslyn,AnthonyDGreen/roslyn,natgla/roslyn,danielcweber/roslyn,JakeGinnivan/roslyn,brettfo/roslyn,REALTOBIZ/roslyn,heejaechang/roslyn,devharis/roslyn,enginekit/roslyn,GuilhermeSa/roslyn,dovzhikova/roslyn,weltkante/roslyn,agocke/roslyn,orthoxerox/roslyn,poizan42/roslyn,bartdesmet/roslyn,natgla/roslyn,CaptainHayashi/roslyn,a-ctor/roslyn,ljw1004/roslyn,tannergooding/roslyn,tmat/roslyn,jmarolf/roslyn,abock/roslyn,hanu412/roslyn,michalhosala/roslyn,mirhagk/roslyn,taylorjonl/roslyn,zooba/roslyn,tsdl2013/roslyn,jrharmon/roslyn,AlexisArce/roslyn,a-ctor/roslyn,OmniSharp/roslyn,drognanar/roslyn,ErikSchierboom/roslyn,stjeong/roslyn,antonssonj/roslyn,eriawan/roslyn,KirillOsenkov/roslyn,brettfo/roslyn,mmitche/roslyn,v-codeel/roslyn,jroggeman/roslyn,basoundr/roslyn,xoofx/roslyn,DinoV/roslyn,leppie/roslyn,akrisiun/roslyn,wvdd007/roslyn,tmeschter/roslyn,jbhensley/roslyn,OmarTawfik/roslyn,REALTOBIZ/roslyn,Hosch250/roslyn,AdamSpeight2008/roslyn-AdamSpeight2008,OmarTawfik/roslyn,v-codeel/roslyn,russpowers/roslyn,paulvanbrenk/roslyn,swaroop-sridhar/roslyn,KevinRansom/roslyn,reaction1989/roslyn,ahmedshuhel/roslyn,tmeschter/roslyn,jeffanders/roslyn,huoxudong125/roslyn,OmarTawfik/roslyn,natgla/roslyn,jmarolf/roslyn,AArnott/roslyn,droyad/roslyn,supriyantomaftuh/roslyn,xasx/roslyn,khellang/roslyn,mseamari/Stuff,Pvlerick/roslyn,ericfe-ms/roslyn,mmitche/roslyn,ahmedshuhel/roslyn,khellang/roslyn,bbarry/roslyn,AmadeusW/roslyn,drognanar/roslyn,MichalStrehovsky/roslyn,YOTOV-LIMITED/roslyn,FICTURE7/roslyn,swaroop-sridhar/roslyn,balajikris/roslyn,jeremymeng/roslyn,AlekseyTs/roslyn,KevinH-MS/roslyn,ilyes14/roslyn,MatthieuMEZIL/roslyn,jcouv/roslyn,FICTURE7/roslyn,MavenRain/roslyn,nguerrera/roslyn,MattWindsor91/roslyn,nguerrera/roslyn,dovzhikova/roslyn,ilyes14/roslyn,Hosch250/roslyn,mattwar/roslyn,vcsjones/roslyn,YOTOV-LIMITED/roslyn,HellBrick/roslyn,doconnell565/roslyn,supriyantomaftuh/roslyn,SeriaWei/roslyn,natidea/roslyn,GuilhermeSa/roslyn,srivatsn/roslyn,oocx/roslyn,VSadov/roslyn,vslsnap/roslyn,vslsnap/roslyn,RipCurrent/roslyn,drognanar/roslyn,mavasani/roslyn,Maxwe11/roslyn,DanielRosenwasser/roslyn,abock/roslyn,VPashkov/roslyn,nagyistoce/roslyn,danielcweber/roslyn,rgani/roslyn,agocke/roslyn,basoundr/roslyn,shyamnamboodiripad/roslyn,cybernet14/roslyn,Inverness/roslyn,REALTOBIZ/roslyn,grianggrai/roslyn,amcasey/roslyn,nemec/roslyn,balajikris/roslyn,michalhosala/roslyn,genlu/roslyn,SeriaWei/roslyn,devharis/roslyn,VitalyTVA/roslyn,mseamari/Stuff,davkean/roslyn,dovzhikova/roslyn,EricArndt/roslyn,bartdesmet/roslyn,lorcanmooney/roslyn,gafter/roslyn,kelltrick/roslyn,jroggeman/roslyn,ericfe-ms/roslyn,enginekit/roslyn,panopticoncentral/roslyn,aelij/roslyn,jamesqo/roslyn,pjmagee/roslyn,budcribar/roslyn,lorcanmooney/roslyn,tang7526/roslyn,KiloBravoLima/roslyn,cybernet14/roslyn,moozzyk/roslyn,FICTURE7/roslyn,khyperia/roslyn,hanu412/roslyn,diryboy/roslyn,panopticoncentral/roslyn