void BuildProjectFails()
        {
            CreateSolutionBuild(@"d:\projects\MyProject\MySolution.sln");
            string projectFileName = @"d:\projects\MyProject\MyProject.csproj";

            solutionHelper.AddProjectToSolutionWithFileName("MyProject", projectFileName);
            BuildProjectResultHasBuildError();
            solutionBuild.BuildProject("Debug", "MyProject.csproj", true);
        }
Ejemplo n.º 2
0
        private void PublishItemCallback(object sender, EventArgs e)
        {
            if (_dte.SelectedItems.Count != 1)
            {
                return;
            }

            SelectedItem item        = _dte.SelectedItems.Item(1);
            ProjectItem  projectItem = item.ProjectItem;

            if (projectItem.IsDirty)
            {
                MessageBoxResult result = MessageBox.Show("Save item and publish?", "Unsaved Item",
                                                          MessageBoxButton.YesNo);

                if (result != MessageBoxResult.Yes)
                {
                    return;
                }

                projectItem.Save();
            }

            //Build TypeScript project
            if (projectItem.Name.ToUpper().EndsWith("TS"))
            {
                SolutionBuild solutionBuild = _dte.Solution.SolutionBuild;
                solutionBuild.BuildProject(_dte.Solution.SolutionBuild.ActiveConfiguration.Name, projectItem.ContainingProject.UniqueName, true);
            }

            CrmConn selectedConnection = (CrmConn)SharedGlobals.GetGlobal("SelectedConnection", _dte);

            if (selectedConnection == null)
            {
                return;
            }

            Guid webResourceId = GetMapping(projectItem, selectedConnection);

            if (webResourceId == Guid.Empty)
            {
                return;
            }

            CrmServiceClient connection = new CrmServiceClient(selectedConnection.ConnectionString);
            //CrmConnection connection = CrmConnection.Parse(selectedConnection.ConnectionString);

            //Check if < CRM 2011 UR12 (ExecuteMutliple)
            Version version = Version.Parse(selectedConnection.Version);

            if (version.Major == 5 && version.Revision < 3200)
            {
                UpdateAndPublishSingle(connection, projectItem, webResourceId);
            }
            else
            {
                UpdateAndPublishMultiple(connection, projectItem, webResourceId);
            }
        }
        public static bool BuildProject(Project project)
        {
            if (!(Package.GetGlobalService(typeof(DTE)) is DTE dte))
            {
                return(false);
            }

            SolutionBuild solutionBuild = dte.Solution.SolutionBuild;

            solutionBuild.BuildProject(dte.Solution.SolutionBuild.ActiveConfiguration.Name, project.UniqueName, true);

            //0 = no errors
            return(solutionBuild.LastBuildInfo <= 0);
        }
Ejemplo n.º 4
0
        public /*async*/ Task <bool> BuildProject(ProjectInfo project)
        {
            DTE           dte           = (DTE)_serviceProvider.GetService(typeof(DTE));
            SolutionBuild solutionBuild = dte.Solution.SolutionBuild;

            string solutionConfiguration = solutionBuild.ActiveConfiguration.Name;

            GeneralUtils.ReportStatus($"Build: {project.Name}");

            // TODO: 2017-01 Bnaya, Use the async version
            solutionBuild.BuildProject(solutionConfiguration, project.FullName, true);
            //await TRD.Tasks.Task.Factory.StartNew(() =>
            //            solutionBuild.BuildProject(solutionConfiguration, project.FullName, true),
            //            TaskCreationOptions.LongRunning);

            bool compiledOK = (solutionBuild.LastBuildInfo == 0);

            if (!compiledOK && System.Diagnostics.Debugger.IsAttached)
            {
                System.Diagnostics.Debugger.Break();
            }
            return(TRD.Tasks.Task.FromResult(compiledOK));
        }
Ejemplo n.º 5
0
        private bool UpdateCrmAssembly(AssemblyItem assemblyItem, CrmServiceClient connection)
        {
            _dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);

            try
            {
                string outputFileName = ConnPane.SelectedProject.Properties.Item("OutputFileName").Value.ToString();
                string path           = GetOutputPath() + outputFileName;

                //Build the project
                SolutionBuild solutionBuild = _dte.Solution.SolutionBuild;
                solutionBuild.BuildProject(_dte.Solution.SolutionBuild.ActiveConfiguration.Name, ConnPane.SelectedProject.UniqueName, true);

                if (solutionBuild.LastBuildInfo > 0)
                {
                    return(false);
                }

                //Make sure Major and Minor versions match
                Version assemblyVersion = Version.Parse(ConnPane.SelectedProject.Properties.Item("AssemblyVersion").Value.ToString());
                if (assemblyItem.Version.Major != assemblyVersion.Major ||
                    assemblyItem.Version.Minor != assemblyVersion.Minor)
                {
                    _logger.WriteToOutputWindow("Error Updating Assembly In CRM: Changes To Major & Minor Versions Require Redeployment", Logger.MessageType.Error);
                    return(false);
                }

                //Make sure assembly names match
                string assemblyName = ConnPane.SelectedProject.Properties.Item("AssemblyName").Value.ToString();
                if (assemblyName.ToUpper() != assemblyItem.Name.ToUpper())
                {
                    _logger.WriteToOutputWindow("Error Updating Assembly In CRM: Changes To Assembly Name Require Redeployment", Logger.MessageType.Error);
                    return(false);
                }

                //Update CRM
                using (OrganizationService orgService = new OrganizationService(connection))
                {
                    Entity crmAssembly = new Entity("pluginassembly")
                    {
                        Id = assemblyItem.AssemblyId
                    };
                    crmAssembly["content"] = Convert.ToBase64String(File.ReadAllBytes(path));

                    orgService.Update(crmAssembly);
                }

                //Update assembly name and version numbers
                assemblyItem.Version      = assemblyVersion;
                assemblyItem.Name         = ConnPane.SelectedProject.Properties.Item("AssemblyName").Value.ToString();
                assemblyItem.DisplayName  = assemblyItem.Name + " (" + assemblyVersion + ")";
                assemblyItem.DisplayName += (assemblyItem.IsWorkflowActivity) ? " [Workflow]" : " [Plug-in]";

                return(true);
            }
            catch (FaultException <OrganizationServiceFault> crmEx)
            {
                _logger.WriteToOutputWindow("Error Updating Assembly In CRM: " + crmEx.Message + Environment.NewLine + crmEx.StackTrace, Logger.MessageType.Error);
                return(false);
            }
            catch (Exception ex)
            {
                _logger.WriteToOutputWindow("Error Updating Assembly In CRM: " + ex.Message + Environment.NewLine + ex.StackTrace, Logger.MessageType.Error);
                return(false);
            }
            finally
            {
                _dte.StatusBar.Clear();
                _dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
            }
        }
Ejemplo n.º 6
0
        private void UpdateAndPublishSingle(CrmServiceClient client, Project project)
        {
            try
            {
                _dte.StatusBar.Text = "Deploying assembly...";
                _dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);

                string outputFileName = project.Properties.Item("OutputFileName").Value.ToString();
                string path           = GetOutputPath(project) + outputFileName;

                //Build the project
                SolutionBuild solutionBuild = _dte.Solution.SolutionBuild;
                solutionBuild.BuildProject(_dte.Solution.SolutionBuild.ActiveConfiguration.Name, project.UniqueName, true);

                if (solutionBuild.LastBuildInfo > 0)
                {
                    return;
                }

                //Make sure Major and Minor versions match
                Version assemblyVersion = Version.Parse(project.Properties.Item("AssemblyVersion").Value.ToString());
                if (SelectedAssemblyItem.Item.Version.Major != assemblyVersion.Major ||
                    SelectedAssemblyItem.Item.Version.Minor != assemblyVersion.Minor)
                {
                    _logger.WriteToOutputWindow("Error Updating Assembly In CRM: Changes To Major & Minor Versions Require Redeployment", Logger.MessageType.Error);
                    return;
                }

                //Make sure assembly names match
                string assemblyName = project.Properties.Item("AssemblyName").Value.ToString();
                if (assemblyName.ToUpper() != SelectedAssemblyItem.Item.Name.ToUpper())
                {
                    _logger.WriteToOutputWindow("Error Updating Assembly In CRM: Changes To Assembly Name Require Redeployment", Logger.MessageType.Error);
                    return;
                }

                //Update CRM
                Entity crmAssembly = new Entity("pluginassembly")
                {
                    Id = SelectedAssemblyItem.Item.AssemblyId
                };
                crmAssembly["content"] = Convert.ToBase64String(File.ReadAllBytes(path));

                client.OrganizationServiceProxy.Update(crmAssembly);

                //Update assembly name and version numbers
                SelectedAssemblyItem.Item.Version      = assemblyVersion;
                SelectedAssemblyItem.Item.Name         = project.Properties.Item("AssemblyName").Value.ToString();
                SelectedAssemblyItem.Item.DisplayName  = SelectedAssemblyItem.Item.Name + " (" + assemblyVersion + ")";
                SelectedAssemblyItem.Item.DisplayName += (SelectedAssemblyItem.Item.IsWorkflowActivity) ? " [Workflow]" : " [Plug-in]";
            }
            catch (FaultException <OrganizationServiceFault> crmEx)
            {
                _logger.WriteToOutputWindow("Error Deploying Report To CRM: " + crmEx.Message + Environment.NewLine + crmEx.StackTrace, Logger.MessageType.Error);
            }
            catch (Exception ex)
            {
                _logger.WriteToOutputWindow("Error Deploying Report To CRM: " + ex.Message + Environment.NewLine + ex.StackTrace, Logger.MessageType.Error);
            }

            _dte.StatusBar.Clear();
            _dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
        }
Ejemplo n.º 7
0
 public void BuildProject(string SolutionConfiguration, string ProjectUniqueName, bool WaitForBuildToFinish = false)
 {
     _build.BuildProject(SolutionConfiguration, ProjectUniqueName, WaitForBuildToFinish);
 }