Update validator.exe and shim.exe (#2024)

* Update Newtonsoft.Json and improve validator build process

* Improve shimexe build process and create deterministic builds
This commit is contained in:
Richard Kuhnt
2018-02-20 18:48:02 +01:00
committed by GitHub
parent 158a6de0c7
commit f0a15886f2
26 changed files with 132 additions and 20 deletions

View File

@@ -230,7 +230,7 @@ function shim($path, $global, $name, $arg) {
if($path -match '\.exe$') { if($path -match '\.exe$') {
# for programs with no awareness of any shell # for programs with no awareness of any shell
cp "$(versiondir 'scoop' 'current')\supporting\shimexe\shim.exe" "$shim.exe" -force cp "$(versiondir 'scoop' 'current')\supporting\shimexe\bin\shim.exe" "$shim.exe" -force
write-output "path = $resolved_path" | out-file "$shim.shim" -encoding utf8 write-output "path = $resolved_path" | out-file "$shim.shim" -encoding utf8
if($arg) { if($arg) {
write-output "args = $arg" | out-file "$shim.shim" -encoding utf8 -append write-output "args = $arg" | out-file "$shim.shim" -encoding utf8 -append

1
supporting/shimexe/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
packages/

View File

@@ -0,0 +1 @@
0fb0a1d75fd6776841345fb99bae4d6db888732fed9ed9a5a1b9c1fad2020379 *shim.exe

View File

@@ -0,0 +1 @@
1239df21ed8ca1c6b5a0f8fba21c8bf16345605478a3c08899fb7d1d8ba9985ed40d41ce6354bdf05a475de3884557dd8359adc24ff99b32286a5aeda11291b7 *shim.exe

Binary file not shown.

View File

@@ -1,5 +1,18 @@
$fwdir = gci C:\Windows\Microsoft.NET\Framework\ -dir | sort -desc | select -first 1 Push-Location $psscriptroot
. "$psscriptroot\..\..\lib\install.ps1"
pushd $psscriptroot Write-Host "Install dependencies ..."
& "$($fwdir.fullname)\csc.exe" /nologo shim.cs Invoke-Expression "$psscriptroot\install.ps1"
popd
$output = "$psscriptroot\bin"
Write-Output 'Compiling shim.cs ...'
& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /out:"$output\shim.exe" shim.cs
Write-Output 'Computing checksums ...'
Remove-Item "$psscriptroot\bin\checksum.sha256" -ErrorAction Ignore
Remove-Item "$psscriptroot\bin\checksum.sha512" -ErrorAction Ignore
Get-ChildItem "$psscriptroot\bin\*" -Include *.exe,*.dll | ForEach-Object {
"$(compute_hash $_ 'sha256') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha256" -Append -Encoding oem
"$(compute_hash $_ 'sha512') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha512" -Append -Encoding oem
}
Pop-Location

View File

@@ -0,0 +1,8 @@
# https://github.com/edymtt/nugetstandalone
$destinationFolder = "$psscriptroot\packages"
if ((Test-Path -path $destinationFolder)) {
Remove-Item -Path $destinationFolder -Recurse | Out-Null
}
New-Item $destinationFolder -Type Directory | Out-Null
nuget install packages.config -o $destinationFolder -ExcludeVersion

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Net.Compilers" version="2.6.1" targetFramework="net40" developmentDependency="true" />
</packages>

View File

@@ -8,7 +8,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace shim { namespace Scoop {
class Program { class Program {
[DllImport("kernel32.dll", SetLastError=true)] [DllImport("kernel32.dll", SetLastError=true)]

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" />
<Import Project="packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props')" />
<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>{381F9D2E-2355-4F84-9206-06BB9175F97B}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Scoop.Shim</RootNamespace>
<AssemblyName>Scoop.Shim</AssemblyName>
<TargetFrameworkVersion>v4.0.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="shim.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props'))" />
</Target>
</Project>

Binary file not shown.

View File

@@ -0,0 +1,10 @@
# https://github.com/edymtt/nugetstandalone
$destinationFolder = "$psscriptroot\packages"
if (!(Test-Path -path $destinationFolder)) {
Write-Host -f Red "Run .\install.ps1 first!"
exit 1
}
nuget update packages.config -r $destinationFolder
Remove-Item $destinationFolder -Force -Recurse | Out-Null
nuget install packages.config -o $destinationFolder -ExcludeVersion

View File

@@ -83,6 +83,16 @@ namespace Scoop
public bool Validate() public bool Validate()
{ {
if (!this.SchemaFile.Exists)
{
Console.WriteLine("ERROR: Please provide schema.json!");
return false;
}
if (!this.ManifestFile.Exists)
{
Console.WriteLine("ERROR: Please provide manifest.json!");
return false;
}
this.Errors.Clear(); this.Errors.Clear();
try try
{ {

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,4 @@
52cc6ddf77990fbaaae4db593f655610652133ceeadb32262c122d8c9eea1bad *Newtonsoft.Json.dll
8643f860be0e5592e73219b6d5e993265f336d3bf2c93d6db5a2e918d3c3f177 *Newtonsoft.Json.Schema.dll
306de31359895c96e1b91df29a216b65a7aa3f353251ba3e5ad129906fcfc77b *Scoop.Validator.dll
cc82c9659716b564a69690a8b67e5472ea1e8e060b974306314acdd42767bf6d *validator.exe

View File

@@ -0,0 +1,4 @@
4639a7f77f7a9cafa38c632332dd5085355623f3d84475374241a64bd110569f504086b479b519e90ddbd471d4a5034239418ebc03277424212e0e6698e64418 *Newtonsoft.Json.dll
0c39a3c8e514fde4d629f11f94e6c7acdcd196cd1229c3ef5a6a0455c1cdf4dbf3fda24dd9392b05e917cb85ec745393595086078d1437343dded52f2c0011f3 *Newtonsoft.Json.Schema.dll
d133d47dbeda60571090fc4159e3575b40ddaddef858b56e0103ad531dc4612a9d4bdbee8a6b5dd4e0d5abeb549afadd059767058b568e4d5d31990a42631743 *Scoop.Validator.dll
384d22bfb21b2767de862f95945dca91aefb4b5eca687d20e410dc64059c5402a13c085517cb807635ff07397fee9bda31b0fdc0090c24cb424f62b285ea0477 *validator.exe

View File

@@ -1,6 +1,21 @@
pushd $psscriptroot Push-Location $psscriptroot
iex "$psscriptroot\install.ps1" . "$psscriptroot\..\..\lib\install.ps1"
gci $psscriptroot\packages\Newtonsoft.*\lib\net40\*.dll -file | % { copy-item $_ $psscriptroot }
& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:library /reference:Newtonsoft.Json.dll,Newtonsoft.Json.Schema.dll Scoop.Validator.cs Write-Host "Install dependencies ..."
& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /reference:Scoop.Validator.dll,Newtonsoft.Json.dll,Newtonsoft.Json.Schema.dll validator.cs Invoke-Expression "$psscriptroot\install.ps1"
popd
$output = "$psscriptroot\bin"
Get-ChildItem "$psscriptroot\packages\Newtonsoft.*\lib\net40\*.dll" -File | ForEach-Object { Copy-Item $_ $output }
Write-Output 'Compiling Scoop.Validator.cs ...'
& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:library /reference:"$output\Newtonsoft.Json.dll","$output\Newtonsoft.Json.Schema.dll" /out:"$output\Scoop.Validator.dll" Scoop.Validator.cs
Write-Output 'Compiling validator.cs ...'
& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /reference:"$output\Scoop.Validator.dll","$output\Newtonsoft.Json.dll","$output\Newtonsoft.Json.Schema.dll" /out:"$output\validator.exe" validator.cs
Write-Output 'Computing checksums ...'
Remove-Item "$psscriptroot\bin\checksum.sha256" -ErrorAction Ignore
Remove-Item "$psscriptroot\bin\checksum.sha512" -ErrorAction Ignore
Get-ChildItem "$psscriptroot\bin\*" -Include *.exe,*.dll | ForEach-Object {
"$(compute_hash $_ 'sha256') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha256" -Append -Encoding oem
"$(compute_hash $_ 'sha512') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha512" -Append -Encoding oem
}
Pop-Location

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" /> <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" />
<package id="Newtonsoft.Json.Schema" version="3.0.3" targetFramework="net40" /> <package id="Newtonsoft.Json.Schema" version="3.0.5" targetFramework="net40" />
<package id="Microsoft.Net.Compilers" version="2.3.2" targetFramework="net40" developmentDependency="true" /> <package id="Microsoft.Net.Compilers" version="2.6.1" targetFramework="net40" developmentDependency="true" />
</packages> </packages>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" />
<Import Project="packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props')" /> <Import Project="packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
@@ -19,7 +20,7 @@
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json.Schema, Version=3.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"> <Reference Include="Newtonsoft.Json.Schema, Version=3.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>packages\Newtonsoft.Json.Schema.3.0.3\lib\net40\Newtonsoft.Json.Schema.dll</HintPath> <HintPath>packages\Newtonsoft.Json.Schema.3.0.5\lib\net40\Newtonsoft.Json.Schema.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
@@ -44,5 +45,6 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props'))" /> <Error Condition="!Exists('packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props'))" />
</Target> </Target>
</Project> </Project>

View File

@@ -6,7 +6,8 @@ $project_file_exclusions = @(
$([regex]::Escape($repo_dir)+'(\\|/).git(\\|/).*$'), $([regex]::Escape($repo_dir)+'(\\|/).git(\\|/).*$'),
'.sublime-workspace$', '.sublime-workspace$',
'.DS_Store$', '.DS_Store$',
'supporting(\\|/)validator(\\|/)packages(\\|/)*' 'supporting(\\|/)validator(\\|/)packages(\\|/)*',
'supporting(\\|/)shimexe(\\|/)packages(\\|/)*'
) )
describe 'Project code' { describe 'Project code' {

View File

@@ -6,9 +6,9 @@ describe "manifest-validation" {
beforeall { beforeall {
$working_dir = setup_working "manifest" $working_dir = setup_working "manifest"
$schema = "$psscriptroot/../schema.json" $schema = "$psscriptroot/../schema.json"
Add-Type -Path "$psscriptroot\..\supporting\validator\Newtonsoft.Json.dll" Add-Type -Path "$psscriptroot\..\supporting\validator\bin\Newtonsoft.Json.dll"
Add-Type -Path "$psscriptroot\..\supporting\validator\Newtonsoft.Json.Schema.dll" Add-Type -Path "$psscriptroot\..\supporting\validator\bin\Newtonsoft.Json.Schema.dll"
Add-Type -Path "$psscriptroot\..\supporting\validator\Scoop.Validator.dll" Add-Type -Path "$psscriptroot\..\supporting\validator\bin\Scoop.Validator.dll"
} }
it "Scoop.Validator is available" { it "Scoop.Validator is available" {