- Verifies dependencies that are tightly coupled are in the set
 of candidates for pushing
This commit is contained in:
David Fowler 2014-03-26 01:10:14 -07:00
Коммит e5558fbb25
11 изменённых файлов: 518 добавлений и 0 удалений

50
.gitattributes поставляемый Normal file
Просмотреть файл

@ -0,0 +1,50 @@
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.jpg binary
*.png binary
*.gif binary
*.cs text=auto diff=csharp
*.vb text=auto
*.resx text=auto
*.c text=auto
*.cpp text=auto
*.cxx text=auto
*.h text=auto
*.hxx text=auto
*.py text=auto
*.rb text=auto
*.java text=auto
*.html text=auto
*.htm text=auto
*.css text=auto
*.scss text=auto
*.sass text=auto
*.less text=auto
*.js text=auto
*.lisp text=auto
*.clj text=auto
*.sql text=auto
*.php text=auto
*.lua text=auto
*.m text=auto
*.asm text=auto
*.erl text=auto
*.fs text=auto
*.fsx text=auto
*.hs text=auto
*.csproj text=auto
*.vbproj text=auto
*.fsproj text=auto
*.dbproj text=auto
*.sln text=auto eol=crlf

24
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,24 @@
[Oo]bj/
[Bb]in/
TestResults/
.nuget/
_ReSharper.*/
packages/
artifacts/
PublishProfiles/
*.user
*.suo
*.cache
*.docstates
_ReSharper.*
nuget.exe
*net45.csproj
*k10.csproj
*.psess
*.vsp
*.pidb
*.userprefs
*DS_Store
*.ncrunchsolution
*.*sdf
*.ipch

22
Coherence.sln Normal file
Просмотреть файл

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30313.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SanityCheck", "src\SanityCheck\SanityCheck.csproj", "{97E8F9C0-208B-43E8-B509-3BBFCB9D3C1D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{97E8F9C0-208B-43E8-B509-3BBFCB9D3C1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97E8F9C0-208B-43E8-B509-3BBFCB9D3C1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97E8F9C0-208B-43E8-B509-3BBFCB9D3C1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97E8F9C0-208B-43E8-B509-3BBFCB9D3C1D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

13
NuGet.Config Normal file
Просмотреть файл

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" />
<add key="NuGet.org" value="https://nuget.org/api/v2/" />
</packageSources>
<packageSourceCredentials>
<AspNetVNext>
<add key="Username" value="aspnetreadonly" />
<add key="ClearTextPassword" value="4d8a2d9c-7b80-4162-9978-47e918c9658c" />
</AspNetVNext>
</packageSourceCredentials>
</configuration>

24
build.cmd Normal file
Просмотреть файл

@ -0,0 +1,24 @@
@echo off
cd %~dp0
SETLOCAL
SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe
IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'"
:copynuget
IF EXIST .nuget\nuget.exe goto restore
md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul
:restore
IF EXIST packages\KoreBuild goto run
.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
.nuget\NuGet.exe restore
.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion
:run
packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*

29
makefile.shade Normal file
Просмотреть файл

@ -0,0 +1,29 @@
use namespace="System"
use namespace="System.Diagnostics"
use namespace="System.IO"
use import="Files"
use import="BuildEnv"
default BASE_DIR='${Directory.GetCurrentDirectory()}'
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}'
default SRC_DIR='${Path.Combine(BASE_DIR, "src")}'
default DROP_SHARE='${Environment.GetEnvironmentVariable("DROP_SHARE")}'
default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'
default SANITY_CHECKER='${Path.Combine(SRC_DIR, "SanityCheck")}'
use-standard-lifecycle
#compile-sanity-check target='compile'
build projectFile='${Path.Combine(SANITY_CHECKER, "SanityCheck.csproj")}'
#copy-bits target='package'
@{
if (String.IsNullOrEmpty(DROP_SHARE))
{
Log.Warn("DROP_SHARE environment varible is not set");
Environment.Exit(-1);
return;
}
}
exec program='${Path.Combine(SANITY_CHECKER, "bin", "Release", "SanityCheck.exe")}' commandline='${DROP_SHARE} ${BUILD_DIR}'

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

243
src/SanityCheck/Program.cs Normal file
Просмотреть файл

@ -0,0 +1,243 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NuGet;
namespace SanityCheck
{
class Program
{
static int Main(string[] args)
{
if (args.Length < 2)
{
Console.WriteLine("Usage: SanityCheck [dropFolder] [outputPath]");
return 1;
}
string dropFolder = args[0];
string outputPath = args[1];
var di = new DirectoryInfo(dropFolder);
var packages = new Dictionary<string, PackageInfo>(StringComparer.OrdinalIgnoreCase);
var projectsToAllowLooseDependencies = new[]{
"CoreCLR"
};
var projectsToSkip = new[] {
"KRuntime",
"Coherence"
};
foreach (var projectFolder in di.EnumerateDirectories())
{
if (projectsToSkip.Contains(projectFolder.Name, StringComparer.OrdinalIgnoreCase))
{
continue;
}
var latestPath = Path.Combine(projectFolder.FullName, "dev", "Latest");
if (!Directory.Exists(latestPath))
{
WriteError("Couldn't find latest for {0}", latestPath);
continue;
}
var build = new DirectoryInfo(Path.Combine(latestPath, "build"));
if (!build.Exists)
{
WriteError("Can't find build dir for {0}", projectFolder.Name);
continue;
}
bool allowLooseDependency = projectsToAllowLooseDependencies.Contains(projectFolder.Name,
StringComparer.OrdinalIgnoreCase);
foreach (var packageInfo in build.EnumerateFiles("*.nupkg"))
{
Console.WriteLine("Processing " + packageInfo + "...");
Retry(() =>
{
var zipPackage = new ZipPackage(packageInfo.FullName);
packages[zipPackage.Id] = new PackageInfo
{
Package = zipPackage,
PackagePath = packageInfo.FullName,
AllowMismatchedDependency = allowLooseDependency
};
});
}
}
if (!VerifyAll(packages))
{
return 1;
}
Directory.CreateDirectory(outputPath);
foreach (var packageInfo in packages.Values.Where(pi => pi.Success))
{
var path = Path.Combine(outputPath, Path.GetFileName(packageInfo.PackagePath));
Retry(() =>
{
File.Copy(packageInfo.PackagePath, outputPath, overwrite: true);
});
Console.WriteLine("Copied to {0}", outputPath);
}
return 0;
}
private static bool VerifyAll(Dictionary<string, PackageInfo> universe)
{
foreach (var packageInfo in universe.Values)
{
Visit(packageInfo, universe);
}
bool success = true;
foreach (var packageInfo in universe.Values)
{
var mismatches = packageInfo.DependencyMismatches.Where(d => !d.Info.AllowMismatchedDependency)
.ToList();
if (mismatches.Any())
{
WriteError("{0} has mismatched dependencies:", packageInfo.Package.GetFullName());
foreach (var mismatch in mismatches)
{
WriteError(" Expected {0}({1}) but got {2}",
mismatch.Dependency,
(mismatch.TargetFramework == VersionUtility.UnsupportedFrameworkName ?
"k10" :
VersionUtility.GetShortFrameworkName(mismatch.TargetFramework)),
mismatch.Info.Package.Version);
success = false;
}
}
}
return success;
}
private static void WriteWarning(string value, params object[] args)
{
Console.WriteLine(value, args);
}
private static void WriteError(string value, params object[] args)
{
if (Environment.GetEnvironmentVariable("TEAMCITY_VERSION") != null)
{
Console.Error.WriteLine("##teamcity[message text='" + value + "' status='ERROR']", args);
}
else
{
Console.Error.WriteLine(value, args);
}
}
private static void Visit(PackageInfo packageInfo, Dictionary<string, PackageInfo> universe)
{
foreach (var dependencySet in packageInfo.Package.DependencySets)
{
foreach (var dependency in dependencySet.Dependencies)
{
// For any dependency in the universe
PackageInfo dependencyPackageInfo;
if (universe.TryGetValue(dependency.Id, out dependencyPackageInfo))
{
if (dependencyPackageInfo.Package.Version !=
dependency.VersionSpec.MinVersion)
{
// Add a mismatch if the min version doesn't work out
// (we only really care about >= minVersion)
packageInfo.DependencyMismatches.Add(new DependencyMismatch
{
Dependency = dependency,
TargetFramework = dependencySet.TargetFramework,
Info = dependencyPackageInfo
});
}
}
}
}
}
private static void Retry(Action action)
{
int attempts = 3;
while (true)
{
try
{
action();
break;
}
catch (FileNotFoundException ex)
{
attempts--;
if (attempts == 0)
{
throw;
}
Console.WriteLine(ex);
Console.WriteLine("Retrying...");
Thread.Sleep(3000);
}
}
}
public class PackageInfo
{
// Some packages we're not as strict about
public bool AllowMismatchedDependency { get; set; }
// The actual package instance
public IPackage Package { get; set; }
// The path to this package
public string PackagePath { get; set; }
public bool Success
{
get
{
return DependencyMismatches.Count == 0 ||
DependencyMismatches.All(d => d.Info.AllowMismatchedDependency);
}
}
public IList<DependencyMismatch> DependencyMismatches { get; set; }
public PackageInfo()
{
DependencyMismatches = new List<DependencyMismatch>();
}
}
public class DependencyMismatch
{
public PackageDependency Dependency { get; set; }
public PackageInfo Info { get; set; }
public FrameworkName TargetFramework { get; set; }
}
}
}

Просмотреть файл

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SanityCheck")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SanityCheck")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4cf7fe5c-0c26-4289-9b92-fb7823c4f6e5")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{97E8F9C0-208B-43E8-B509-3BBFCB9D3C1D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SanityCheck</RootNamespace>
<AssemblyName>SanityCheck</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.XmlTransform">
<HintPath>..\..\packages\Microsoft.Web.Xdt.1.0.0\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
</Reference>
<Reference Include="NuGet.Core, Version=2.8.50126.400, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\NuGet.Core.2.8.0\lib\net40-Client\NuGet.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.Xdt" version="1.0.0" targetFramework="net45" />
<package id="NuGet.Core" version="2.8.0" targetFramework="net45" />
</packages>