Skip to content

Commit 751840c

Browse files
committed
paket full .net core, as .net core tool
both paket and paket.bootstrapper convert Paket.Bootstrapper to .net sdk: - appsettings not supported on .net core - system web proxy not supported on .net core - ssl3 is deprecated on .net core
1 parent 471e570 commit 751840c

File tree

10 files changed

+150
-5
lines changed

10 files changed

+150
-5
lines changed

Paket.preview3.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Paket.Core", "src/Paket.Cor
77
EndProject
88
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Paket", "src/Paket.preview3/Paket.fsproj", "{6CA5144C-5444-46E8-9B89-86122B5E2D32}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paket.Bootstrapper", "src/Paket.Bootstrapper.preview3/Paket.Bootstrapper.csproj", "{8CC1605A-307B-4B68-876D-1D38ED48EA4D}"
11+
EndProject
1012
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{90759A76-746D-4599-9BCC-E10F8D2E1355}"
1113
EndProject
1214
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Paket.Tests", "tests/Paket.Tests.preview3/Paket.Tests.fsproj", "{0156FA92-AF44-4242-B76F-18D0A367A8B2}"
@@ -57,6 +59,18 @@ Global
5759
{BCF3D1A7-724E-4E33-AC88-70984B3CC03A}.Release|x64.Build.0 = Release|x64
5860
{BCF3D1A7-724E-4E33-AC88-70984B3CC03A}.Release|x86.ActiveCfg = Release|x86
5961
{BCF3D1A7-724E-4E33-AC88-70984B3CC03A}.Release|x86.Build.0 = Release|x86
62+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Debug|x64.ActiveCfg = Debug|x64
65+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Debug|x64.Build.0 = Debug|x64
66+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Debug|x86.ActiveCfg = Debug|x86
67+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Debug|x86.Build.0 = Debug|x86
68+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
69+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Release|Any CPU.Build.0 = Release|Any CPU
70+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Release|x64.ActiveCfg = Release|x64
71+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Release|x64.Build.0 = Release|x64
72+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Release|x86.ActiveCfg = Release|x86
73+
{8CC1605A-307B-4B68-876D-1D38ED48EA4D}.Release|x86.Build.0 = Release|x86
6074
EndGlobalSection
6175
GlobalSection(SolutionProperties) = preSolution
6276
HideSolutionNode = FALSE

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "2.1.4"
3+
"version": "2.1.300-rc1-008673"
44
}
55
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
<AssemblyName>paket.bootstrapper</AssemblyName>
7+
<PackAsTool>true</PackAsTool>
8+
9+
<PaketBootstrapperSourcesDir>..\Paket.Bootstrapper</PaketBootstrapperSourcesDir>
10+
<DefineConstants>
11+
NO_APPSETTINGS;
12+
NO_SSL3;
13+
NO_SYSTEMWEBPROXY;
14+
PAKET_BOOTSTRAP_AS_TOOL;
15+
PAKET_BOOTSTRAP_TO_DIR;
16+
$(DefineConstants)
17+
</DefineConstants>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<Compile Include="$(PaketBootstrapperSourcesDir)\ArgumentParser.cs" />
22+
<Compile Include="$(PaketBootstrapperSourcesDir)\BootstrapperHelper.cs" />
23+
<Compile Include="$(PaketBootstrapperSourcesDir)\BootstrapperOptions.cs" />
24+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadStrategies\IDownloadStrategy.cs" />
25+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadStrategies\IHaveEffectiveStrategy.cs" />
26+
<Compile Include="$(PaketBootstrapperSourcesDir)\PaketHashFile.cs" />
27+
<Compile Include="$(PaketBootstrapperSourcesDir)\Properties\InternalsVisibleTo.cs" />
28+
<Compile Include="$(PaketBootstrapperSourcesDir)\PaketDependencies.cs" />
29+
<Compile Include="$(PaketBootstrapperSourcesDir)\PaketRunner.cs" />
30+
<Compile Include="$(PaketBootstrapperSourcesDir)\Verbosity.cs" />
31+
<Compile Include="$(PaketBootstrapperSourcesDir)\WindowsProcessArguments.cs" />
32+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadStrategies\CacheDownloadStrategy.cs" />
33+
<Compile Include="$(PaketBootstrapperSourcesDir)\HelperProxies\IWebRequestProxy.cs" />
34+
<Compile Include="$(PaketBootstrapperSourcesDir)\HelperProxies\WebRequestProxy.cs" />
35+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadArguments.cs" />
36+
<Compile Include="$(PaketBootstrapperSourcesDir)\EnvProxy.cs" />
37+
<Compile Include="$(PaketBootstrapperSourcesDir)\HelperProxies\FileSystemProxy.cs" />
38+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadStrategies\GitHubDownloadStrategy.cs" />
39+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadStrategies\DownloadStrategy.cs" />
40+
<Compile Include="$(PaketBootstrapperSourcesDir)\HelperProxies\IFileSystemProxy.cs" />
41+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadStrategies\NugetDownloadStrategy.cs" />
42+
<Compile Include="$(PaketBootstrapperSourcesDir)\ConsoleImpl.cs" />
43+
<Compile Include="$(PaketBootstrapperSourcesDir)\Program.cs" />
44+
<Compile Include="$(PaketBootstrapperSourcesDir)\SemVer.cs" />
45+
<Compile Include="$(PaketBootstrapperSourcesDir)\DownloadStrategies\TemporarilyIgnoreUpdatesDownloadStrategy.cs" />
46+
<Compile Include="$(PaketBootstrapperSourcesDir)\HelperProxies\DateTimeProxy.cs" />
47+
</ItemGroup>
48+
49+
</Project>

src/Paket.Bootstrapper/ArgumentParser.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,27 @@ private static void FillTarget(DownloadArguments downloadArguments, bool magicMo
5252
downloadArguments.Folder = Path.GetDirectoryName(target);
5353
}
5454

55+
private static void FillTargetToRelativeDir(DownloadArguments downloadArguments, IFileSystemProxy fileSystem)
56+
{
57+
var folder = fileSystem.GetCurrentDirectory();
58+
var target = Path.Combine(folder, "paket.exe");
59+
60+
downloadArguments.Target = target;
61+
downloadArguments.Folder = Path.GetDirectoryName(target);
62+
}
63+
5564
public static BootstrapperOptions ParseArgumentsAndConfigurations(IEnumerable<string> arguments, NameValueCollection appSettings, IDictionary envVariables, IFileSystemProxy fileSystem, IEnumerable<string> argumentsInDependenciesFile)
5665
{
5766
var options = new BootstrapperOptions();
5867
var commandArgs = arguments.ToList();
5968
var magicMode = GetIsMagicMode(fileSystem);
6069
var transparentMagicMode = magicMode && commandArgs.IndexOf(CommandArgs.Run) == -1;
6170

71+
#if PAKET_BOOTSTRAP_TO_DIR
72+
FillTargetToRelativeDir(options.DownloadArguments, fileSystem);
73+
#else
6274
FillTarget(options.DownloadArguments, magicMode, fileSystem);
75+
#endif
6376

6477
// 1 - AppSettings
6578
FillOptionsFromAppSettings(options, appSettings);

src/Paket.Bootstrapper/BootstrapperHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ internal static IWebProxy GetDefaultWebProxyFor(String url)
9494
if (EnvProxy.TryGetProxyFor(uri, out result) && result.GetProxy(uri) != uri)
9595
return result;
9696

97+
#if NO_SYSTEMWEBPROXY
98+
return null;
99+
#else
97100
result = WebRequest.GetSystemWebProxy();
98101
Uri address = result.GetProxy(uri);
99102
if (address == uri)
@@ -104,6 +107,7 @@ internal static IWebProxy GetDefaultWebProxyFor(String url)
104107
Credentials = CredentialCache.DefaultCredentials,
105108
BypassProxyOnLocal = true
106109
};
110+
#endif
107111
}
108112

109113
internal static void FileMove(string oldPath, string newPath)

src/Paket.Bootstrapper/DownloadStrategies/NugetDownloadStrategy.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ internal class NugetApiHelper
2525
public NugetApiHelper(string packageName, string nugetSource)
2626
{
2727
this.packageName = packageName;
28+
#if NO_APPSETTINGS
29+
this.nugetSource = nugetSource ?? DefaultNugetSource;
30+
#else
2831
this.nugetSource = nugetSource ?? ConfigurationManager.AppSettings[NugetSourceAppSettingsKey] ?? DefaultNugetSource;
32+
#endif
2933
}
3034

3135
internal string GetAllPackageVersions(bool includePrerelease)
@@ -163,12 +167,59 @@ protected override void DownloadVersionCore(string latestVersion, string target,
163167
}
164168
}
165169

170+
#if PAKET_BOOTSTRAP_AS_TOOL
171+
string toolWorkDir = Path.Combine(FileSystemProxy.GetCurrentDirectory());
172+
// 1 - generate custom nuget.config
173+
string bootstrapperNugetConfig = CreateNugetConfigForBootstrapper(randomFullPath, FileSystemProxy);
174+
// 2 - install as tool
175+
int exitCode = Dotnet(String.Format(@"tool install paket --version {2} --tool-path ""{0}"" --configfile ""{1}""", toolWorkDir, bootstrapperNugetConfig, latestVersion));
176+
if (exitCode != 0) {
177+
Environment.Exit(exitCode);
178+
}
179+
#else
166180
FileSystemProxy.ExtractToDirectory(paketPackageFile, randomFullPath);
167181
var paketSourceFile = Path.Combine(randomFullPath, "tools", "paket.exe");
168182
FileSystemProxy.CopyFile(paketSourceFile, target, true);
183+
#endif
169184
FileSystemProxy.DeleteDirectory(randomFullPath, true);
170185
}
171186

187+
public static string CreateNugetConfigForBootstrapper(string paketToolNupkgDir, IFileSystemProxy fileSystem)
188+
{
189+
string path = Path.GetTempFileName();
190+
var text = new[]
191+
{
192+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
193+
"<configuration>",
194+
"<packageSources>",
195+
" <!--To inherit the global NuGet package sources remove the <clear/> line below -->",
196+
" <clear />",
197+
string.Format(" <add key=\"download_paket_tool\" value=\"{0}\" />", paketToolNupkgDir),
198+
"</packageSources>",
199+
"</configuration>"
200+
};
201+
File.WriteAllText(path, string.Join(System.Environment.NewLine, text));
202+
return path;
203+
}
204+
205+
public static int Dotnet(string argString)
206+
{
207+
ConsoleImpl.WriteInfo("Running dotnet {0}", argString);
208+
var process = new System.Diagnostics.Process
209+
{
210+
StartInfo =
211+
{
212+
FileName = "dotnet",
213+
Arguments = argString,
214+
CreateNoWindow = true,
215+
UseShellExecute = false
216+
}
217+
};
218+
process.Start();
219+
process.WaitForExit();
220+
return process.ExitCode;
221+
}
222+
172223
protected override void SelfUpdateCore(string latestVersion)
173224
{
174225
string target = Assembly.GetExecutingAssembly().Location;

src/Paket.Bootstrapper/Program.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,32 @@ static void Main(string[] args)
2323
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
2424
| SecurityProtocolType.Tls11
2525
| SecurityProtocolType.Tls
26+
#if NO_SSL3
27+
;
28+
#else
2629
| SecurityProtocolType.Ssl3;
30+
#endif
31+
2732
executionWatch.Start();
2833
Console.CancelKeyPress += CancelKeyPressed;
2934

3035
var fileProxy = new FileSystemProxy();
31-
var optionsBeforeDependenciesFile = ArgumentParser.ParseArgumentsAndConfigurations(args, ConfigurationManager.AppSettings,
36+
37+
var appSettings =
38+
#if NO_APPSETTINGS
39+
new System.Collections.Specialized.NameValueCollection();
40+
#else
41+
ConfigurationManager.AppSettings;
42+
#endif
43+
44+
var optionsBeforeDependenciesFile = ArgumentParser.ParseArgumentsAndConfigurations(args, appSettings,
3245
Environment.GetEnvironmentVariables(), fileProxy, Enumerable.Empty<string>());
3346
ConsoleImpl.Verbosity = optionsBeforeDependenciesFile.Verbosity;
3447

3548
var argumentsFromDependenciesFile =
3649
WindowsProcessArguments.Parse(
3750
PaketDependencies.GetBootstrapperArgsForFolder(fileProxy));
38-
var options = ArgumentParser.ParseArgumentsAndConfigurations(args, ConfigurationManager.AppSettings,
51+
var options = ArgumentParser.ParseArgumentsAndConfigurations(args, appSettings,
3952
Environment.GetEnvironmentVariables(), fileProxy, argumentsFromDependenciesFile);
4053
if (options.ShowHelp)
4154
{

src/Paket.Core/embedded/Paket.Restore.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
1515
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
1616
<!-- Paket command -->
17+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket')">$(PaketToolsPath)paket</PaketExePath>
1718
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
1819
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
1920
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>

src/Paket.preview3/Paket.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
55
<AssemblyName>paket</AssemblyName>
66
</PropertyGroup>
77
<!--<Win32Resource>paket.res</Win32Resource>-->

tests/Paket.Tests.preview3/Paket.Tests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.0</TargetFramework>
3+
<TargetFramework>netcoreapp2.1</TargetFramework>
44
<PaketTestsSourcesDir>..\Paket.Tests</PaketTestsSourcesDir>
55
<DefineConstants>WEBPROXY_NETSTANDARD;$(DefineConstants)</DefineConstants>
66
</PropertyGroup>

0 commit comments

Comments
 (0)