private void InnerExecute()
    {
        var path = DestinationFolder.FullPath();

        Directory.CreateDirectory(path);

        var propertyProvider = new PropertyProvider()
        {
            { "version", GitVersionInformation.NuGetVersionV2 }
        };

        var packageBuilder = new PackageBuilder();

        using (var spec = File.OpenRead(NuSpecFile.FullPath()))
        {
            var manifest = Manifest.ReadFrom(spec, propertyProvider, false);
            packageBuilder.Populate(manifest.Metadata);
        }

        packageBuilder.PopulateFiles("", new[] { new ManifestFile {
                                                     Source = ReferenceLibrary.FullPath(), Target = "lib"
                                                 } });

        var debug = Path.ChangeExtension(ReferenceLibrary.FullPath(), ".pdb");

        if (File.Exists(debug))
        {
            packageBuilder.PopulateFiles("", new[] { new ManifestFile {
                                                         Source = debug, Target = "lib"
                                                     } });
        }

        if (File.Exists(PackagesConfig.FullPath()))
        {
            var dependencies = new List <PackageDependency>();

            var doc = XDocument.Load(PackagesConfig.FullPath());

            var packages = doc.Descendants()
                           .Where(x => x.Name == "package" && x.Attribute("developmentDependency")?.Value != "true")
                           .Select(p => new { id = p.Attribute("id").Value, version = SemanticVersion.Parse(p.Attribute("version").Value) })
                           .Select(p => new PackageDependency(p.id, new VersionSpec()
            {
                IsMinInclusive = true, MinVersion = p.version
            }));

            dependencies.AddRange(packages);

            packageBuilder.DependencySets.Add(new PackageDependencySet(null, dependencies));
        }

        var packagePath = Path.Combine(path, packageBuilder.GetFullName() + ".nupkg");

        using (var file = new FileStream(packagePath, FileMode.Create))
        {
            Log.LogMessage($"Saving file {packagePath}");

            packageBuilder.Save(file);
        }
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         LoadAllUpgrades();
         _instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Ejemplo n.º 3
0
        /// <summary>Create a installer code unit to compile.</summary>
        /// <returns>
        ///     <see cref="CodeCompileUnit" />
        /// </returns>
        public static CodeCompileUnit CreateInstallerCode()
        {
            CodeCompileUnit _codeUnit = new CodeCompileUnit();

            // References
            _codeUnit.ReferencedAssemblies.Add("System.dll");
            _codeUnit.ReferencedAssemblies.Add("Comet.dll");

            // Namespace
            CodeNamespace _namespace = new CodeNamespace("Installer");

            // Using/s
            _namespace.Imports.Add(new CodeNamespaceImport("System"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Diagnostics"));
            _namespace.Imports.Add(new CodeNamespaceImport("Comet"));

            _codeUnit.Namespaces.Add(_namespace);

            // Class
            CodeTypeDeclaration _class = new CodeTypeDeclaration("CometInstall");

            _class.Attributes = MemberAttributes.Public;
            _class.Comments.Add(CodeGeneration.CreateFlatSummaryTag("The main class."));

            // if (false)
            // {
            // _class.BaseTypes.Add(new CodeTypeReference("Base"));
            // }

            // Create entry point method
            CodeEntryPointMethod _entryPointMethod = CodeGeneration.MainEntryPointMethod();

            _entryPointMethod.Statements.Add(CodeGeneration.InvokeMethod(ReferenceLibrary.InstallerType(), "Initialize"));
            _class.Members.Add(_entryPointMethod);

            // Create public variables
            _class.Members.Add(CodeGeneration.CreatePublicProperty("InstallPath", typeof(string)));
            _class.Members.Add(CodeGeneration.CreatePublicProperty("DownloadLink", typeof(string)));

            CodeMemberMethod _initializeMethod = InitializeMethod();

            _class.Members.Add(_initializeMethod);

            _namespace.Types.Add(_class);

            return(_codeUnit);
        }
Ejemplo n.º 4
0
 public static string Path(this ReferenceLibrary val) => MockVbeBuilder.ReferenceLibraryIdentifiers[val].Path;
Ejemplo n.º 5
0
 /// <summary>Method: WriteLine.</summary>
 /// <param name="message">The message to write.</param>
 /// <returns>
 ///     <see cref="CodeMethodInvokeExpression" />
 /// </returns>
 public static CodeMethodInvokeExpression WriteLineExpression(string message)
 {
     return(new CodeMethodInvokeExpression(ReferenceLibrary.SystemConsoleType(), "WriteLine", new CodePrimitiveExpression(message)));
 }
Ejemplo n.º 6
0
 /// <summary>Method: ReadLine.</summary>
 /// <returns>
 ///     <see cref="CodeMethodInvokeExpression" />
 /// </returns>
 public static CodeMethodInvokeExpression ReadLineExpression()
 {
     return(new CodeMethodInvokeExpression(ReferenceLibrary.SystemConsoleType(), "ReadLine"));
 }
Ejemplo n.º 7
0
 /// <summary>Method: Execute comet method.</summary>
 /// <param name="method">The method.</param>
 /// <returns>
 ///     <see cref="CodeMethodInvokeExpression" />
 /// </returns>
 public static CodeMethodInvokeExpression ExecuteCometMethod(string method)
 {
     return(new CodeMethodInvokeExpression(ReferenceLibrary.CometType(), method));
 }
 /// <summary>
 /// Adds a mock reference to the project.
 /// </summary>
 /// <param name="referenceLibrary">The reference library's enum.</param>
 /// <returns>Returns the <see cref="MockProjectBuilder"/> instance.</returns>
 public MockProjectBuilder AddReference(ReferenceLibrary referenceLibrary)
 {
     var(name, path, versionMajor, versionMinor, isBuiltIn) = MockVbeBuilder.ReferenceLibraries[referenceLibrary];
     return(AddReference(name, path, versionMajor, versionMinor, isBuiltIn));
 }
Ejemplo n.º 9
0
        private static CodeMemberMethod InitializeMethod()
        {
            CodeMemberMethod _initializeMethod = new CodeMemberMethod();

            _initializeMethod.Comments.Add(CodeGeneration.CreateFlatSummaryTag("The initialize method."));

            // Variables
            CodeMethodInvokeExpression _stringDownloadLink = CodeGeneration.ToString("DownloadLink");
            CodeMethodInvokeExpression _stringInstallPath  = CodeGeneration.ToString("InstallPath");

            // CodeMethodInvokeExpression _stringInstallDirectory = ToString("");
            CodeMethodInvokeExpression _writeDownloadLink = new CodeMethodInvokeExpression(ReferenceLibrary.SystemConsoleType(), "WriteLine", _stringDownloadLink);
            CodeMethodInvokeExpression _writeInstallPath  = new CodeMethodInvokeExpression(ReferenceLibrary.SystemConsoleType(), "WriteLine", _stringInstallPath);

            // CodeMethodInvokeExpression _writeInstallDirectory = new CodeMethodInvokeExpression(ReferenceLibrary.SystemConsoleType(), "WriteLine", _stringInstallPath);
            _initializeMethod.Name       = "Initialize";
            _initializeMethod.Attributes = MemberAttributes.Static;
            _initializeMethod.ReturnType = new CodeTypeReference(typeof(void));

            _initializeMethod.Statements.Add(CodeGeneration.SetTitle("Comet"));
            _initializeMethod.Statements.Add(CodeGeneration.WriteLineExpression("Comet Console Debug"));

            // Initialize variables
            _initializeMethod.Statements.Add(CodeGeneration.SetDownloadPath("https://raw.githubusercontent.com/DarkByte7/Comet/master/Comet/Update.package"));
            _initializeMethod.Statements.Add(CodeGeneration.SetInstallPath("Comet.Managers.ApplicationManager.GetMainModuleFileName()"));

            // Output
            _initializeMethod.Statements.Add(CodeGeneration.WriteLineExpression("Download link:"));
            _initializeMethod.Statements.Add(_writeDownloadLink);
            _initializeMethod.Statements.Add(CodeGeneration.WriteLineExpression("Install path:"));
            _initializeMethod.Statements.Add(_writeInstallPath);

            // _initializeMethod.Statements.Add(MethodInvoke.WriteLineExpression("Install directory:"));

            // ReadLine
            _initializeMethod.Statements.Add(CodeGeneration.ReadLineExpression());

            return(_initializeMethod);
        }
 private int ArrangeParserAndGetResultCount(string inputCode, ReferenceLibrary library = ReferenceLibrary.Scripting)
 => InspectionResultsForModules(("Codez", inputCode, ComponentType.StandardModule), library).Count();