Пример #1
0
        public bool IsPackagingTargetsInstalled(string projectFilePath)
        {
            var loggers = new IMSBuildLogger[] { new ConsoleLogger(LoggerVerbosity.Quiet) };
            var project = new MSBuild.Project(projectFilePath);

            if (!project.Build("Restore", loggers))
            {
                Console.Error.WriteLine($"Failed to restore '{Path.GetFileName(projectFilePath)}'. Please run dotnet restore, and try again.");
                return(false);
            }

            var projectAssetsPath = project.GetPropertyValue("ProjectAssetsFile");

            // NuGet has a LockFileUtilities.GetLockFile API which provides direct access to this file format,
            // but loading NuGet in the same process as MSBuild creates dependency conflicts.
            LockFile lockFile = null;

            using (StreamReader reader = File.OpenText(projectAssetsPath))
                using (JsonReader jsonReader = new JsonTextReader(reader))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    lockFile = serializer.Deserialize <LockFile>(jsonReader);
                }

            if (!lockFile.Libraries.Any(l => l.Key.StartsWith("Packaging.Targets/")))
            {
                Console.Error.WriteLine($"The project '{Path.GetFileName(projectFilePath)}' doesn't have a PackageReference to Packaging.Targets.");
                Console.Error.WriteLine($"Please run 'dotnet {this.commandName} install', and try again.");
                return(false);
            }

            return(true);
        }
Пример #2
0
        public void RemoveLogger(ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _loggers.Remove(logger);
        }
Пример #3
0
        public void AddLogger(ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _loggers.Add(logger);
        }
Пример #4
0
        public bool IsPackagingTargetsInstalled()
        {
            var projectFilePath = Directory.GetFiles(Environment.CurrentDirectory, "*.csproj").SingleOrDefault();

            if (projectFilePath == null)
            {
                Console.Error.WriteLine($"Failed to find a .csproj file in '{Environment.CurrentDirectory}'. dotnet {this.commandName} only works if");
                Console.Error.WriteLine($"you have exactly one .csproj file in your directory. For advanced scenarios, please use 'dotnet msbuild /t:{this.msbuildTarget}'");
                return(false);
            }

            var loggers = new IMSBuildLogger[] { new ConsoleLogger(LoggerVerbosity.Quiet) };
            var project = new MSBuild.Project(projectFilePath);

            if (!project.Build("Restore", loggers))
            {
                Console.Error.WriteLine($"Failed to restore '{Path.GetFileName(projectFilePath)}'. Please run dotnet restore, and try again.");
                return(false);
            }

            var projectAssetsPath = project.GetPropertyValue("ProjectAssetsFile");

            // NuGet has a LockFileUtilities.GetLockFile API which provides direct access to this file format,
            // but loading NuGet in the same process as MSBuild creates dependency conflicts.
            LockFile lockFile = null;

            using (StreamReader reader = File.OpenText(projectAssetsPath))
                using (JsonReader jsonReader = new JsonTextReader(reader))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    lockFile = serializer.Deserialize <LockFile>(jsonReader);
                }

            if (!lockFile.Libraries.Any(l => l.Key.StartsWith("Packaging.Targets/")))
            {
                Console.Error.WriteLine($"The project '{Path.GetFileName(projectFilePath)}' doesn't have a PackageReference to Packaging.Targets.");
                Console.Error.WriteLine($"Please run 'dotnet {this.commandName} install', and try again.");
                return(false);
            }

            return(true);
        }
Пример #5
0
 public void RegisterLogger(int submissionId, Microsoft.Build.Framework.ILogger logger)
 {
 }
Пример #6
0
 public void RegisterLogger(Microsoft.Build.Framework.ILogger logger)
 {
 }
Пример #7
0
 public void RegisterDistributedLogger(Microsoft.Build.Framework.ILogger centralLogger, Microsoft.Build.BuildEngine.LoggerDescription forwardingLogger)
 {
 }
 public ShopifyOrderFulfilledHandler(ILogger <ShopifyOrderFulfilledHandler> logger, ShopifyConfig config)
 {
     _logger = logger;
     _config = config;
 }
Пример #9
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
             base.Initialize();

             // Add our command handlers for menu (commands must exist in the .vsct file)
             OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
             if (null != mcs)
             {
            // Create the command for the menu item.
            CommandID menuCommandID = new CommandID(GuidList.guidProjectCmdSet, (int)PkgCmdIDList.cmdidRunSim);
            MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
            mcs.AddCommand(menuItem);
            // Create the command for the tool window
            CommandID toolwndCommandID = new CommandID(GuidList.guidProjectCmdSet, (int)PkgCmdIDList.cmdidSimOutput);
            MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
            mcs.AddCommand(menuToolWin);
             }

             ProjectUtilities.SetServiceProvider(this);

             msBuildLogger = new VSOutputLogger(this);

             this.RegisterProjectFactory(new BlenXProjectFactory(this));
        }