Skip to content

Commit

Permalink
Merge pull request #239 from gigya/develop
Browse files Browse the repository at this point in the history
#80260, Relax conditions for NSubstitute, greater or equal to 3.1
  • Loading branch information
achirlin authored Feb 18, 2019
2 parents c3f4a69 + f713eec commit ca8ebfa
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 95 deletions.
67 changes: 67 additions & 0 deletions .paket/set.copy.local.false.libs.linq
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<Query Kind="Statements">
<NuGetReference>Gigya.Build.Solo</NuGetReference>
<Namespace>Gigya.Build.Solo</Namespace>
<Namespace>Gigya.Build.Solo.Command</Namespace>
</Query>

//
// Run, to stop visual studio complile projects again and again.
// 1.0.2
// A.Chirlin, 2019/02/16
//
// Since upgrade to 4.7.2 there is negative impact on compilation time, VS recompiles again and again the projects despite absence of changes.
// Such behavior is result of facade (design time references) not actually copied to bin, but recognized as missing and triggering rebuild.
// More about how I found this behavior in: https://michaelscodingspot.com/2017/04/28/visual-studio-keeps-rebuilding-projects-no-good-reason/
//
// Why script?
// Every time you running paket install, ooops the properties will be rewritten.
//

var scriptDir = Path.GetDirectoryName(Util.CurrentQueryPath);
var filesTxt = Path.GetFileNameWithoutExtension(Util.CurrentQueryPath) + ".txt";
var slnFile = new FileInfo(Path.Combine(scriptDir, "..", "Microdot.sln")).FullName;

var s = new Solution(slnFile);
var designTime = @"c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades";
var affected = new List<string>();
var exclude = new[]{"System.ValueTuple", "System.ComponentModel.Annotations"}; // I paid attention, for some reason these are still copied, despite is it design time

foreach (var project in s.Projects.OrderBy(p=>p.FullName))
{
// load project XML
var xmlDoc = new XmlDocument();
var projectFile = project.FullName;
xmlDoc.Load(projectFile);
var ns = xmlDoc.DocumentElement.Attributes["xmlns"].InnerText;
var mgr = new XmlNamespaceManager(xmlDoc.NameTable);
mgr.AddNamespace("a", ns);

// Find all references with Private = True (meaning copy local true).
// If this reference in design time folder, meaning msbuild won't copy it despite copy local true AND it causing rebuild (as not found in output folder).
// Such reference apparently has no meaning of copy local and we can convert to False.
// I found few exceptions from rule above, that despite the reference resides in design time (facade) folder, it is still copied by msbuild. Why? It is same name and public key token ...
// So far, I narrowed the assemblies to System.* nuget packages and installed by paket only.
var hasChanges = false;
foreach (XmlAttribute element in xmlDoc.SelectNodes(@"//a:Reference[a:Private[.='True'] and a:Paket[.='True']]/@Include[starts-with(.,'System.')]", mgr))
{
var reference = element.Value;

if(!exclude.Contains(reference))
if (File.Exists(Path.Combine(designTime, reference + ".dll")))
{
var @private = element.OwnerElement.SelectSingleNode("a:Private[.='True']", mgr);
@private.InnerText = "False";
hasChanges = true;
affected.Add(reference);
}
}

if (hasChanges)
{
xmlDoc.Save(projectFile);
projectFile.Dump();
}
}

affected.Distinct().OrderBy(r=>r).ToList().Dump("Affected references:");
exclude.Dump("Excluded references:");
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
</Reference>
<Reference Include="System.AppContext">
<HintPath>..\packages\System.AppContext\lib\net463\System.AppContext.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -279,7 +279,7 @@
<ItemGroup>
<Reference Include="System.Console">
<HintPath>..\packages\System.Console\lib\net46\System.Console.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -290,7 +290,7 @@
<ItemGroup>
<Reference Include="System.Diagnostics.FileVersionInfo">
<HintPath>..\packages\System.Diagnostics.FileVersionInfo\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -301,7 +301,7 @@
<ItemGroup>
<Reference Include="System.Diagnostics.StackTrace">
<HintPath>..\packages\System.Diagnostics.StackTrace\lib\net46\System.Diagnostics.StackTrace.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -312,7 +312,7 @@
<ItemGroup>
<Reference Include="System.IO">
<HintPath>..\packages\System.IO\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -323,7 +323,7 @@
<ItemGroup>
<Reference Include="System.IO.FileSystem">
<HintPath>..\packages\System.IO.FileSystem\lib\net46\System.IO.FileSystem.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -334,7 +334,7 @@
<ItemGroup>
<Reference Include="System.IO.FileSystem.Primitives">
<HintPath>..\packages\System.IO.FileSystem.Primitives\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -345,7 +345,7 @@
<ItemGroup>
<Reference Include="System.Linq">
<HintPath>..\packages\System.Linq\lib\net463\System.Linq.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -356,7 +356,7 @@
<ItemGroup>
<Reference Include="System.Linq.Expressions">
<HintPath>..\packages\System.Linq.Expressions\lib\net463\System.Linq.Expressions.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -367,7 +367,7 @@
<ItemGroup>
<Reference Include="System.Reflection">
<HintPath>..\packages\System.Reflection\lib\net462\System.Reflection.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -392,7 +392,7 @@
</Reference>
<Reference Include="System.Runtime">
<HintPath>..\packages\System.Runtime\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -414,7 +414,7 @@
<ItemGroup>
<Reference Include="System.Runtime.Extensions">
<HintPath>..\packages\System.Runtime.Extensions\lib\net462\System.Runtime.Extensions.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -425,7 +425,7 @@
<ItemGroup>
<Reference Include="System.Runtime.InteropServices">
<HintPath>..\packages\System.Runtime.InteropServices\lib\net463\System.Runtime.InteropServices.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -445,7 +445,7 @@
<ItemGroup>
<Reference Include="System.Security.Cryptography.Algorithms">
<HintPath>..\packages\System.Security.Cryptography.Algorithms\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -456,7 +456,7 @@
<ItemGroup>
<Reference Include="System.Security.Cryptography.Encoding">
<HintPath>..\packages\System.Security.Cryptography.Encoding\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -467,7 +467,7 @@
<ItemGroup>
<Reference Include="System.Security.Cryptography.Primitives">
<HintPath>..\packages\System.Security.Cryptography.Primitives\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -478,7 +478,7 @@
<ItemGroup>
<Reference Include="System.Security.Cryptography.X509Certificates">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand Down Expand Up @@ -511,7 +511,7 @@
<ItemGroup>
<Reference Include="System.Threading.Thread">
<HintPath>..\packages\System.Threading.Thread\lib\net46\System.Threading.Thread.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -522,7 +522,7 @@
<ItemGroup>
<Reference Include="System.Xml.ReaderWriter">
<HintPath>..\packages\System.Xml.ReaderWriter\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -533,7 +533,7 @@
<ItemGroup>
<Reference Include="System.Xml.XmlDocument">
<HintPath>..\packages\System.Xml.XmlDocument\lib\net46\System.Xml.XmlDocument.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -544,7 +544,7 @@
<ItemGroup>
<Reference Include="System.Xml.XPath">
<HintPath>..\packages\System.Xml.XPath\lib\net46\System.Xml.XPath.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand All @@ -555,7 +555,7 @@
<ItemGroup>
<Reference Include="System.Xml.XPath.XDocument">
<HintPath>..\packages\System.Xml.XPath.XDocument\lib\net46\System.Xml.XPath.XDocument.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Microdot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{0F8FE3
paket.dependencies = paket.dependencies
paket.lock = paket.lock
.paket\restore.bat = .paket\restore.bat
.paket\set.copy.local.false.libs.linq = .paket\set.copy.local.false.libs.linq
.paket\update.bat = .paket\update.bat
EndProjectSection
EndProject
Expand Down Expand Up @@ -176,7 +177,7 @@ Global
{10E10FDE-8A2C-4D5D-8FC1-15FACF844E80} = {79538186-DFAD-463C-B4D1-CD0917CF5954}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8
SolutionGuid = {8A847321-B6B0-4BA9-9AC3-0DB91FA99B90}
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8
EndGlobalSection
EndGlobal
Loading

0 comments on commit ca8ebfa

Please sign in to comment.