コード例 #1
0
 public override void Execute()
 {
     PerformanceUtility.StartPerformanceSequence(PerformanceEvent.ProjectRun);
     if (this.IsEnabled)
     {
         Microsoft.Expression.Framework.UserInterface.IWindowService service = (Microsoft.Expression.Framework.UserInterface.IWindowService)base.Services.GetService(typeof(Microsoft.Expression.Framework.UserInterface.IWindowService));
         if (service != null)
         {
             service.ReturnFocus();
         }
         ISolution            solution            = this.Solution();
         IProjectBuildContext projectBuildContext = solution.ProjectBuildContext;
         IExecutable          startupProject      = solution.StartupProject;
         string str = (projectBuildContext != null ? projectBuildContext.DisplayName : solution.DocumentReference.DisplayName);
         if (startupProject == null || !startupProject.IsExecuting)
         {
             this.HandleBasicExceptions(() => this.BuildAndRun(projectBuildContext, startupProject));
             return;
         }
         CultureInfo currentCulture = CultureInfo.CurrentCulture;
         string      runCommandUnableToRunDialogMessage = StringTable.RunCommandUnableToRunDialogMessage;
         object[]    objArray = new object[] { str };
         this.DisplayCommandFailedMessage(string.Format(currentCulture, runCommandUnableToRunDialogMessage, objArray));
     }
 }
コード例 #2
0
 public BuildCompletedEventArgs(IProjectBuildContext buildTarget, IExecutable executable, Microsoft.Expression.Project.Build.BuildResult buildResult, bool displayOutput)
 {
     this.BuildTarget   = buildTarget;
     this.Executable    = executable;
     this.BuildResult   = buildResult;
     this.DisplayOutput = displayOutput;
 }
コード例 #3
0
 public BuildRequest(IProjectBuildContext buildContext, IExecutable executable, IEnumerable <string> buildTargets, bool displayOutput)
 {
     this.BuildContext  = buildContext;
     this.Executable    = executable;
     this.Targets       = buildTargets;
     this.DisplayOutput = displayOutput;
 }
コード例 #4
0
ファイル: HostLogger.cs プロジェクト: radtek/Shopdrawing
 public HostLogger(IProjectBuildContext buildTarget, IServiceProvider serviceProvider)
 {
     this.buildTarget     = buildTarget;
     this.messageLogger   = (IMessageLoggingService)serviceProvider.GetService(typeof(IMessageLoggingService));
     this.serviceProvider = serviceProvider;
     this.consoleLogger   = new HostLogger.AlterableConsoleLogger(LoggerVerbosity.Normal);
     this.consoleLogger.SetWriter(new WriteHandler(this.Writer));
 }
コード例 #5
0
        private IErrorTaskCollection GetProjectErrorsFromContext()
        {
            IProjectBuildContext activeBuildTarget = this.context.ProjectManager.ActiveBuildTarget;

            if (activeBuildTarget == null)
            {
                return((IErrorTaskCollection)null);
            }
            return(activeBuildTarget.BuildErrors);
        }
コード例 #6
0
ファイル: CleanCommand.cs プロジェクト: radtek/Shopdrawing
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         IProjectBuildContext activeBuildTarget = this.ProjectManager().ActiveBuildTarget;
         IExecutable startupProject             = this.Solution().StartupProject;
         if (startupProject == null || !startupProject.IsExecuting)
         {
             this.ProjectManager().BuildManager.Clean(activeBuildTarget);
             return;
         }
         this.DisplayCommandFailedMessage(string.Format(CultureInfo.CurrentCulture, StringTable.BuildAndRunCommandUnableToBuildDialogMessage, new object[] { activeBuildTarget.DisplayName }));
     });
 }
コード例 #7
0
        public void Build()
        {
            if (!this.IsValid)
            {
                return;
            }
            IExecutable startupProject = this.solution.StartupProject;

            if (startupProject == null || !startupProject.IsExecuting)
            {
                this.solution.Save(false);
                IProjectBuildContext projectBuildContext = this.solution.ProjectBuildContext;
                this.projectManager.BuildManager.Build(projectBuildContext, startupProject, false);
            }
        }
コード例 #8
0
 public override void Execute()
 {
     if (this.IsEnabled)
     {
         this.HandleBasicExceptions(() => {
             IExecutable startupProject = this.Solution().StartupProject;
             if (startupProject != null && startupProject.IsExecuting)
             {
                 this.DisplayCommandFailedMessage(string.Format(CultureInfo.CurrentCulture, StringTable.BuildAndRunCommandUnableToBuildDialogMessage, new object[] { this.Solution().DocumentReference.DisplayName }));
             }
             else if (this.SaveSolution(false))
             {
                 IProjectBuildContext projectBuildContext = this.Solution().ProjectBuildContext;
                 BuildManager buildManager    = this.ProjectManager().BuildManager;
                 buildManager.BuildCompleted += new EventHandler <BuildCompletedEventArgs>(this.BuildFinished);
                 buildManager.Build(projectBuildContext, startupProject, false);
                 return;
             }
         });
     }
 }
コード例 #9
0
 internal void Build(IProjectBuildContext buildTarget, IExecutable executable, bool blockUntilComplete, bool displayOutput)
 {
     string[] strArrays = new string[] { "Build" };
     this.BuildCore(new BuildManager.BuildRequest(buildTarget, executable, strArrays, displayOutput), blockUntilComplete);
 }
コード例 #10
0
 public void Build(IProjectBuildContext buildTarget, IExecutable executable, bool blockUntilComplete)
 {
     string[] strArrays = new string[] { "Build" };
     this.BuildCore(new BuildManager.BuildRequest(buildTarget, executable, strArrays, true), blockUntilComplete);
 }
コード例 #11
0
            private object CompleteBuild(object o)
            {
                IProjectBuildContext buildContext;
                IExecutable          executable;

                try
                {
                    this.buildComplete    = true;
                    BuildManager.building = false;
                    BuildManager.BuildInfo buildInfo = (BuildManager.BuildInfo)o;
                    if (buildInfo.BuildRequest != null)
                    {
                        buildContext = buildInfo.BuildRequest.BuildContext;
                    }
                    else
                    {
                        buildContext = null;
                    }
                    IProjectBuildContext projectBuildContext = buildContext;
                    BuildResult          buildResult         = buildInfo.BuildResult;
                    if (buildInfo.BuildRequest != null)
                    {
                        executable = buildInfo.BuildRequest.Executable;
                    }
                    else
                    {
                        executable = null;
                    }
                    IExecutable executable1 = executable;
                    bool        flag        = (buildInfo.BuildRequest != null ? buildInfo.BuildRequest.DisplayOutput : true);
                    if (projectBuildContext != null)
                    {
                        projectBuildContext.BuildCompleted(buildResult);
                    }
                    if (this.displayFeedback)
                    {
                        if (buildResult == BuildResult.Succeeded)
                        {
                            this.serviceProvider.MessageLoggingService().WriteLine(StringTable.ProjectBuildCompletedMessage);
                        }
                        else if (buildResult != BuildResult.Failed)
                        {
                            this.serviceProvider.MessageLoggingService().WriteLine(StringTable.ProjectBuildCanceledMessage);
                        }
                        else
                        {
                            if (buildInfo.Exception != null)
                            {
                                this.serviceProvider.MessageLoggingService().WriteLine(buildInfo.Exception.ToString());
                            }
                            this.serviceProvider.MessageLoggingService().WriteLine(StringTable.ProjectBuildFailedMessage);
                        }
                        if (buildResult != BuildResult.Succeeded)
                        {
                            this.serviceProvider.ErrorService().DisplayErrors();
                        }
                    }
                    this.buildManager.OnBuildCompleted(new BuildCompletedEventArgs(projectBuildContext, executable1, buildResult, flag), buildInfo.BuildRequest);
                }
                finally
                {
                    BuildManager.currentBuildThread = null;
                    PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ProjectBuild);
                }
                return(null);
            }
コード例 #12
0
 internal void Clean(IProjectBuildContext buildTarget)
 {
     string[] strArrays = new string[] { "Clean" };
     this.BuildCore(new BuildManager.BuildRequest(buildTarget, null, strArrays, true), false);
 }
コード例 #13
0
ファイル: HostLogger.cs プロジェクト: radtek/Shopdrawing
 internal static void LogFormattedWarning(IProjectBuildContext buildTarget, string message, string project, int line, int column, string file)
 {
     buildTarget.BuildErrors.Add(new HostLogger.ErrorTask(ErrorSeverity.Warning, message, project, file, line, column));
 }
コード例 #14
0
 private void BuildAndRun(IProjectBuildContext buildTarget, IExecutable executable)
 {
     if (buildTarget != null)
     {
         VisualStudioSolution visualStudioSolution = buildTarget as VisualStudioSolution;
         IProject             startupProject       = buildTarget as IProject;
         if (startupProject == null && visualStudioSolution != null)
         {
             startupProject = visualStudioSolution.StartupProject as IProject;
         }
         if (startupProject != null && startupProject.GetCapability <bool>("CanHaveStartupItem") && startupProject.StartupItem == null && !this.CapabilitiesAllowNullStartupItem(startupProject))
         {
             if (visualStudioSolution != null)
             {
                 MessageBoxArgs messageBoxArg = new MessageBoxArgs()
                 {
                     Message = StringTable.RunCommandNoStartupSceneWarningMessage,
                     Button  = MessageBoxButton.YesNo,
                     Image   = MessageBoxImage.Exclamation
                 };
                 if (base.Services.ShowSuppressibleWarning(messageBoxArg, "ShowStartupSceneWarning", MessageBoxResult.Yes, visualStudioSolution.SolutionSettingsManager.SolutionSettings) == MessageBoxResult.No)
                 {
                     return;
                 }
             }
             else if (!base.Services.PromptUserYesNo(StringTable.RunCommandNoStartupSceneWarningMessage))
             {
                 return;
             }
         }
         ISolution           solution = buildTarget as ISolution;
         IList <ProjectBase> list     = null;
         if (solution != null)
         {
             list = (
                 from project in solution.Projects.OfType <ProjectBase>()
                 where project.DoesErrorConditionExist("PotentiallyInvalidTransparentCache", NetworkInterface.GetIsNetworkAvailable())
                 select project).ToList <ProjectBase>();
         }
         if (list != null && list.Count > 0)
         {
             StringBuilder stringBuilder = new StringBuilder(128);
             foreach (IProject project1 in list)
             {
                 stringBuilder.AppendLine(string.Concat("\t", project1.Name));
             }
             CultureInfo currentCulture = CultureInfo.CurrentCulture;
             string      runCommandPlatformExtensionsWarningMessage = StringTable.RunCommandPlatformExtensionsWarningMessage;
             object[]    str  = new object[] { stringBuilder.ToString() };
             string      str1 = string.Format(currentCulture, runCommandPlatformExtensionsWarningMessage, str);
             if (visualStudioSolution != null)
             {
                 MessageBoxArgs messageBoxArg1 = new MessageBoxArgs()
                 {
                     Message = str1,
                     Button  = MessageBoxButton.YesNo,
                     Image   = MessageBoxImage.Exclamation
                 };
                 if (base.Services.ShowSuppressibleWarning(messageBoxArg1, "AllowPlatformExtension", MessageBoxResult.Yes, visualStudioSolution.SolutionSettingsManager.SolutionSettings) == MessageBoxResult.No)
                 {
                     return;
                 }
             }
             else if (!base.Services.PromptUserYesNo(str1))
             {
                 return;
             }
         }
     }
     if (this.SaveSolution(false))
     {
         if (buildTarget != null)
         {
             BuildManager buildManager = this.ProjectManager().BuildManager;
             buildManager.BuildCompleted += new EventHandler <BuildCompletedEventArgs>(this.BuildFinished);
             buildManager.Build(buildTarget, executable, false);
             return;
         }
         if (executable != null)
         {
             executable.Execute();
         }
     }
 }
コード例 #15
0
 public BuildStartingEventArgs(IProjectBuildContext buildTarget, bool displayOutput)
 {
     this.BuildTarget   = buildTarget;
     this.DisplayOutput = displayOutput;
 }
コード例 #16
0
        public IEnumerable <IProjectItem> CreateProjectItems(string name, string targetFolder, IProject project, IEnumerable <TemplateArgument> templateArguments, CreationOptions creationOptions, out List <IProjectItem> itemsToOpen, IServiceProvider serviceProvider)
        {
            Uri uri;

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            ICodeDocumentType codeDocumentType = base.GetCodeDocumentType(serviceProvider);

            if (templateArguments != null)
            {
                templateArguments = templateArguments.Concat <TemplateArgument>(TemplateManager.GetDefaultArguments(serviceProvider.ExpressionInformationService()));
            }
            else
            {
                templateArguments = TemplateManager.GetDefaultArguments(serviceProvider.ExpressionInformationService());
            }
            IEnumerable <IProjectItem> projectItems = Enumerable.Empty <IProjectItem>();

            itemsToOpen = new List <IProjectItem>();
            using (ProjectPathHelper.TemporaryDirectory temporaryDirectory = new ProjectPathHelper.TemporaryDirectory(true))
            {
                Uri uri1 = new Uri(Microsoft.Expression.Framework.Documents.PathHelper.EnsurePathEndsInDirectorySeparator(temporaryDirectory.Path));
                List <DocumentCreationInfo> documentCreationInfos = new List <DocumentCreationInfo>();
                List <string> strs = new List <string>();
                bool          flag = false;
                foreach (VSTemplateTemplateContentProjectItem templateProjectItem in this.TemplateProjectItems)
                {
                    if (!templateProjectItem.OpenInEditorSpecified)
                    {
                        continue;
                    }
                    flag = true;
                    break;
                }
                bool             flag1             = false;
                string           str               = CodeGenerator.MakeSafeIdentifier(codeDocumentType, project.DocumentReference.DisplayNameShort, flag1);
                bool             flag2             = true;
                string           str1              = CodeGenerator.MakeSafeIdentifier(codeDocumentType, project.DocumentReference.DisplayNameShort, flag2);
                TemplateArgument templateArgument  = new TemplateArgument("safeprojectname", str);
                TemplateArgument templateArgument1 = new TemplateArgument("safeprojectname", str1);
                TemplateArgument templateArgument2 = new TemplateArgument("assemblyname", project.DocumentReference.DisplayNameShort);
                TemplateArgument templateArgument3 = new TemplateArgument("safeassemblyname", project.DocumentReference.DisplayNameShort.Replace(' ', '\u005F'));
                foreach (VSTemplateTemplateContentProjectItem vSTemplateTemplateContentProjectItem in this.TemplateProjectItems)
                {
                    string targetFileName = vSTemplateTemplateContentProjectItem.TargetFileName;
                    if (string.IsNullOrEmpty(targetFileName))
                    {
                        targetFileName = vSTemplateTemplateContentProjectItem.Value;
                    }
                    TemplateArgument[]             templateArgumentArray = new TemplateArgument[] { new TemplateArgument("fileinputname", Path.GetFileNameWithoutExtension(name)), new TemplateArgument("fileinputextension", Path.GetExtension(name)) };
                    IEnumerable <TemplateArgument> templateArguments1    = templateArgumentArray;
                    targetFileName     = TemplateParser.ReplaceTemplateArguments(targetFileName, templateArguments1);
                    templateArguments1 = templateArguments1.Concat <TemplateArgument>(templateArguments);
                    bool   flag3 = Path.GetExtension(vSTemplateTemplateContentProjectItem.Value).Equals(codeDocumentType.DefaultFileExtension, StringComparison.OrdinalIgnoreCase);
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(Microsoft.Expression.Framework.Documents.PathHelper.GetFileOrDirectoryName(targetFileName));
                    if (serviceProvider.DocumentTypeManager().DocumentTypes[DocumentTypeNamesHelper.Xaml].IsDocumentTypeOf(fileNameWithoutExtension))
                    {
                        fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileNameWithoutExtension);
                    }
                    string str2 = CodeGenerator.MakeSafeIdentifier(codeDocumentType, fileNameWithoutExtension, flag3);
                    IEnumerable <TemplateArgument> templateArguments2     = templateArguments1;
                    TemplateArgument[]             templateArgumentArray1 = new TemplateArgument[] { new TemplateArgument("rootnamespace", project.DefaultNamespaceName), new TemplateArgument("projectname", project.DocumentReference.DisplayNameShort), templateArgument2, templateArgument3, null, null, null, null };
                    templateArgumentArray1[4] = (flag3 ? templateArgument1 : templateArgument);
                    templateArgumentArray1[5] = new TemplateArgument("safeitemname", str2);
                    templateArgumentArray1[6] = new TemplateArgument("safeitemrootname", str2);
                    templateArgumentArray1[7] = new TemplateArgument("culture", (string.IsNullOrEmpty(project.UICulture) ? CultureInfo.CurrentUICulture.ToString() : project.UICulture));
                    templateArguments1        = templateArguments2.Concat <TemplateArgument>(templateArgumentArray1);
                    try
                    {
                        uri = base.ResolveFileUri(targetFileName, uri1);
                    }
                    catch (UriFormatException uriFormatException)
                    {
                        continue;
                    }
                    IDocumentType documentType = project.GetDocumentType(targetFileName);
                    foreach (IDocumentType documentType1 in serviceProvider.DocumentTypeManager().DocumentTypes)
                    {
                        if (vSTemplateTemplateContentProjectItem.SubType != documentType1.Name)
                        {
                            continue;
                        }
                        documentType = documentType1;
                    }
                    if (!base.CreateFile(vSTemplateTemplateContentProjectItem.Value, base.TemplateLocation, uri, vSTemplateTemplateContentProjectItem.ReplaceParameters, templateArguments1))
                    {
                        continue;
                    }
                    string str3 = ProjectItemTemplate.AdjustTargetFolder(targetFolder, uri1.LocalPath, uri.LocalPath);
                    DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo()
                    {
                        SourcePath      = uri.LocalPath,
                        TargetFolder    = str3,
                        DocumentType    = documentType,
                        CreationOptions = creationOptions
                    };
                    documentCreationInfos.Add(documentCreationInfo);
                    if (!flag)
                    {
                        if (strs.Count > 0)
                        {
                            continue;
                        }
                        strs.Add(Path.Combine(str3, Path.GetFileName(uri.LocalPath)));
                    }
                    else
                    {
                        if (!vSTemplateTemplateContentProjectItem.OpenInEditor)
                        {
                            continue;
                        }
                        strs.Add(Path.Combine(str3, Path.GetFileName(uri.LocalPath)));
                    }
                }
                if (documentCreationInfos.Count > 0)
                {
                    projectItems = project.AddItems(documentCreationInfos);
                }
                if (projectItems.Any <IProjectItem>())
                {
                    for (int i = 0; i < strs.Count; i++)
                    {
                        IProjectItem projectItem = projectItems.FirstOrDefault <IProjectItem>((IProjectItem item) => item.DocumentReference.Path.Equals(strs[i], StringComparison.OrdinalIgnoreCase));
                        if (projectItem != null)
                        {
                            itemsToOpen.Add(projectItem);
                        }
                    }
                    projectItems = projectItems.Concat <IProjectItem>(this.AddAssemblies(project));
                }
            }
            if (base.BuildOnLoad)
            {
                IProjectManager      projectManager    = serviceProvider.ProjectManager();
                IProjectBuildContext activeBuildTarget = projectManager.ActiveBuildTarget;
                projectManager.BuildManager.Build(activeBuildTarget, null, true);
                KnownProjectBase knownProjectBase = project as KnownProjectBase;
                if (knownProjectBase != null)
                {
                    knownProjectBase.CheckForChangedOrDeletedItems();
                }
            }
            return(projectItems);
        }