diff --git a/examples/ReferenceNugetPackages.vpack b/examples/ReferenceNugetPackages.vpack
new file mode 100644
index 0000000..0fab111
--- /dev/null
+++ b/examples/ReferenceNugetPackages.vpack
@@ -0,0 +1,14 @@
+
+
+ My Avvvvesome Pack
+ microdee
+
+
+ Newtonsoft.Json
+ EntityFramework
+
+
+ using System;
+ Console.WriteLine("tada");
+
+
diff --git a/src/vpm/Program.cs b/src/vpm/Program.cs
index 12593af..f4abf28 100644
--- a/src/vpm/Program.cs
+++ b/src/vpm/Program.cs
@@ -28,6 +28,7 @@ static void Main(string[] args)
Console.ResetColor();
Console.WriteLine(ArgUsage.GenerateUsageFromTemplate());
VpmUtils.CleanUp();
+ Environment.Exit(0);
}
try
{
diff --git a/src/vpm/config.cs b/src/vpm/config.cs
index 5b43344..e319ea3 100644
--- a/src/vpm/config.cs
+++ b/src/vpm/config.cs
@@ -4,6 +4,7 @@
using System.Reflection;
using System.Windows;
using System.Xml;
+using NuGet;
using PowerArgs;
namespace vpm
@@ -13,6 +14,10 @@ public class VpmConfig
private static VpmConfig _instance;
public static VpmConfig Instance => _instance ?? (_instance = new VpmConfig());
+ private IPackageRepository _defaultNugetRepository;
+ public IPackageRepository DefaultNugetRepository => _defaultNugetRepository ??
+ (_defaultNugetRepository = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2"));
+
private string _vvvvarch;
public string VVVVArcitecture
{
diff --git a/src/vpm/vpack.cs b/src/vpm/vpack.cs
index ef1dfe1..c45e892 100644
--- a/src/vpm/vpack.cs
+++ b/src/vpm/vpack.cs
@@ -5,10 +5,12 @@
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
+using System.Windows.Controls;
using System.Xml;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using PowerArgs;
+using NuGet;
namespace vpm
{
@@ -61,6 +63,7 @@ public class VPack
public string RawXml;
public bool Agreed = false;
public List Aliases = new List();
+ public XmlNodeList NugetPackages;
public List Dependencies = new List();
public VPack(string name, string source, IEnumerable aliases = null, XmlDocument srcxml = null)
@@ -99,7 +102,7 @@ public VPack(string name, string source, IEnumerable aliases = null, Xml
{
RawXml = xmldoc.ToString();
var licensenode = xmldoc.SelectSingleNode("/vpack/meta/license");
- LicenseUrl = licensenode != null ? licensenode.InnerText.Trim() : "http://www.imxprs.com/free/microdee/vpmnolicense";
+ LicenseUrl = licensenode?.InnerText.Trim() ?? "http://www.imxprs.com/free/microdee/vpmnolicense";
var namenode = xmldoc.SelectSingleNode("/vpack/meta/name");
if (namenode == null)
@@ -122,6 +125,12 @@ public VPack(string name, string source, IEnumerable aliases = null, Xml
throw new Exception("VPack doesn't contain installing script.");
}
InstallScript = installnode.InnerText;
+
+ var nugetnode = xmldoc.SelectSingleNode("/vpack/nuget");
+ if (nugetnode != null)
+ {
+ NugetPackages = nugetnode.ChildNodes;
+ }
var dependenciesnode = xmldoc.SelectSingleNode("/vpack/meta/dependencies");
if (dependenciesnode != null)
@@ -241,13 +250,61 @@ public void Install()
{
d.Install();
}
+
+ Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Installing " + Name);
+ Console.ResetColor();
+
var vpmglobal = new VpmGlobals(this);
+ var assemblies = VpmConfig.Instance.ReferencedAssemblies;
+ if (NugetPackages != null && NugetPackages.Count > 0)
+ {
+ Console.WriteLine("Initializing Nuget for this pack");
+ var packdir = Path.Combine(TempDir, "NugetPackages");
+ Directory.CreateDirectory(packdir);
+ var repo = VpmConfig.Instance.DefaultNugetRepository;
+ var packman = new PackageManager(repo, packdir);
+ packman.PackageInstalled += (sender, args) =>
+ {
+ Console.WriteLine("Installed " + args.Package.Id);
+ };
+ for (int i = 0; i < NugetPackages.Count; i++)
+ {
+ var packnode = NugetPackages[i];
+ Console.WriteLine("Installing Nuget Package " + packnode.InnerText);
+ var version = packnode.Attributes?["version"]?.Value;
+
+ var packages = repo.FindPackagesById(packnode.InnerText);
+ IPackage package = null;
+ foreach (var p in packages)
+ {
+ bool versioncheck = p.IsLatestVersion;
+ if (version != null)
+ versioncheck = SemanticVersion.Parse(version) == p.Version;
+
+ if (versioncheck)
+ {
+ package = p;
+ break;
+ }
+ }
+ if (package == null)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine("No nuget package found with those conditions");
+ Console.ResetColor();
+ }
+ else
+ {
+ packman.InstallPackage(package, false, true);
+ }
+ }
+ }
try
{
CSharpScript.EvaluateAsync(InstallScript,
globals: vpmglobal,
- options: ScriptOptions.Default.WithReferences(VpmConfig.Instance.ReferencedAssemblies));
+ options: ScriptOptions.Default.WithReferences(assemblies));
}
catch (CompilationErrorException e)
{