Skip to content

Commit

Permalink
Use a bootstrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Sep 19, 2014
1 parent 9a91532 commit a2f3504
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,4 @@ release.cmd
localpackages/
paket-files
*.orig
paket.exe
Binary file removed .nuget/NuGet.exe
Binary file not shown.
7 changes: 0 additions & 7 deletions Paket.cmd

This file was deleted.

6 changes: 6 additions & 0 deletions Paket.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Paket.Tests", "tests\Paket.
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Paket", "src\Paket\Paket.fsproj", "{09B32F18-0C20-4489-8C83-5106D5C04C93}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paket.Bootstrapper", "src\Paket.Bootstrapper\Paket.Bootstrapper.csproj", "{CE3F8B87-1ABD-462E-A35B-CDCEC695898B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -63,6 +65,10 @@ Global
{09B32F18-0C20-4489-8C83-5106D5C04C93}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09B32F18-0C20-4489-8C83-5106D5C04C93}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09B32F18-0C20-4489-8C83-5106D5C04C93}.Release|Any CPU.Build.0 = Release|Any CPU
{CE3F8B87-1ABD-462E-A35B-CDCEC695898B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE3F8B87-1ABD-462E-A35B-CDCEC695898B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE3F8B87-1ABD-462E-A35B-CDCEC695898B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE3F8B87-1ABD-462E-A35B-CDCEC695898B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@echo off
cls

.nuget\nuget.exe install Paket -OutputDirectory packages -Prerelease -ExcludeVersion
paket.bootstrapper.exe
if errorlevel 1 (
exit /b %errorlevel%
)

packages\Paket\tools\paket.exe install
paket.exe install
if errorlevel 1 (
exit /b %errorlevel%
)
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

mono .nuget/NuGet.exe install Paket -OutputDirectory packages -Prerelease -ExcludeVersion
mono paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi

mono packages/Paket/tools/paket.exe install
mono paket.exe install
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
Expand Down
Binary file added paket.bootstrapper.exe
Binary file not shown.
56 changes: 56 additions & 0 deletions src/Paket.Bootstrapper/Paket.Bootstrapper.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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>{CE3F8B87-1ABD-462E-A35B-CDCEC695898B}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Paket.Bootstrapper</RootNamespace>
<AssemblyName>paket.bootstrapper</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</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="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>
<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>
76 changes: 76 additions & 0 deletions src/Paket.Bootstrapper/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;


namespace Paket.Bootstrapper
{
class Program
{
static void Main(string[] args)
{
try
{
var folder = "";
if (args.Length > 1)
folder = args[0];

var target = Path.Combine(folder, "paket.exe");
var localVersion = "";
if (File.Exists(target))
{
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(target);
localVersion = fvi.FileVersion;
}

using (WebClient client = new WebClient())
{
client.Headers.Add("user-agent", "Paket.Bootstrapper");
var releasesUrl = "https://api.github.com/repos/fsprojects/Paket/releases";
var data = client.DownloadString(releasesUrl);
var start = data.IndexOf("tag_name") + 11;
var end = data.IndexOf("\"", start);
var latestVersion = data.Substring(start, end - start);

if (!localVersion.StartsWith(latestVersion))
{
var url = String.Format("https://github.com/fsprojects/Paket/releases/download/{0}/paket.exe", latestVersion);

Console.WriteLine("Starting download from {0}", url);

var request = (HttpWebRequest)HttpWebRequest.Create(url);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
using (HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse())
{
using (Stream httpResponseStream = httpResponse.GetResponseStream())
{
const int bufferSize = 4096;
byte[] buffer = new byte[bufferSize];
int bytesRead = 0;

using (FileStream fileStream = File.Create(target))
{
while ((bytesRead = httpResponseStream.Read(buffer, 0, bufferSize)) != 0)
{
fileStream.Write(buffer, 0, bytesRead);
}
}
}
}
}
else
{
Console.WriteLine("Paket.exe {0} is up to date.", localVersion);
}
}
}
catch (Exception exn)
{
Environment.ExitCode = 1;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(exn.Message);
}
}
}
}
13 changes: 13 additions & 0 deletions src/Paket.Bootstrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// <auto-generated/>
using System.Reflection;

[assembly: AssemblyTitleAttribute("Paket.Bootstrapper")]
[assembly: AssemblyProductAttribute("Paket")]
[assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub files.")]
[assembly: AssemblyVersionAttribute("0.2.5")]
[assembly: AssemblyFileVersionAttribute("0.2.5")]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "0.2.5";
}
}

0 comments on commit a2f3504

Please sign in to comment.