public override void ProjectCreationComplete()
        {
            TargetFramework fx = Project.CurrentTargetFramework;

            if (fx != null && (fx.IsBasedOn(TargetFramework.Net35) || fx.IsBasedOn(TargetFramework.Net35Client)))
            {
                AddDotnet35References();
            }
            if (fx != null && (fx.IsBasedOn(TargetFramework.Net40) || fx.IsBasedOn(TargetFramework.Net40Client)))
            {
                AddDotnet40References();
            }
            if (fx != null)
            {
                UpdateAppConfig(fx);
            }
            if (Project.OutputType != OutputType.Library)
            {
                if (DotnetDetection.IsDotnet45Installed() && fx.IsBasedOn(TargetFramework.Net45))
                {
                    Project.SetProperty(null, Project.ActivePlatform, "Prefer32Bit", "True", PropertyStorageLocations.PlatformSpecific, true);
                }
                else
                {
                    Project.SetProperty(null, Project.ActivePlatform, "PlatformTarget", "x86", PropertyStorageLocations.PlatformSpecific, true);
                }
            }
            base.ProjectCreationComplete();
        }
        public void Load(MSBuildBasedProject project, string configuration, string platform)
        {
            int val;

            if (!int.TryParse(BaseAddress.Value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out val))
            {
                val = 0x400000;
            }
            DllBaseAddress = "0x" + val.ToString("x", NumberFormatInfo.InvariantInfo);

            this.TargetCPU         = new List <KeyItemPair>();
            supports32BitPreferred = false;
            var outputType = projectOptions.GetProperty("OutputType", OutputType.Exe);

            if (DotnetDetection.IsDotnet45Installed() &&
                ((outputType.Value == OutputType.Exe) || (outputType.Value == OutputType.WinExe)))
            {
                var upgradableProject = projectOptions.Project as IUpgradableProject;
                if (upgradableProject != null && upgradableProject.CurrentTargetFramework != null && upgradableProject.CurrentTargetFramework.Supports32BitPreferredOption)
                {
                    supports32BitPreferred = (projectOptions.Project.MinimumSolutionVersion >= SolutionFormatVersion.VS2010);
                }
                // Show 32 vs. 64 options even for library projects;
                // it's relevant for web applications.
            }
            if (supports32BitPreferred)
            {
                this.TargetCPU.Add(new KeyItemPair("AnyCPU32", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any32}")));
                this.TargetCPU.Add(new KeyItemPair("AnyCPU64", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any64}")));
            }
            else
            {
                this.TargetCPU.Add(new KeyItemPair("AnyCPU", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any}")));
            }
            this.TargetCPU.Add(new KeyItemPair("x86", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x86}")));
            this.TargetCPU.Add(new KeyItemPair("x64", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x64}")));
            this.TargetCPU.Add(new KeyItemPair("Itanium", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Itanium}")));

            if (supports32BitPreferred && string.Equals(this.PlatformTarget.Value, "AnyCPU", StringComparison.OrdinalIgnoreCase))
            {
                bool default32BitPreferred = false;
                var  upgradableProject     = projectOptions.Project as IUpgradableProject;
                if (upgradableProject != null && upgradableProject.CurrentTargetFramework.Supports32BitPreferredOption)
                {
                    default32BitPreferred = true;
                }
                if (Prefer32Bit.Value ?? default32BitPreferred)
                {
                    targetCpuComboBox.SelectedValue = "AnyCPU32";
                }
                else
                {
                    targetCpuComboBox.SelectedValue = "AnyCPU64";
                }
            }
            else
            {
                targetCpuComboBox.SelectedValue = this.PlatformTarget.Value;
            }
        }
示例#3
0
        public override IEnumerable <CompilerVersion> GetAvailableCompilerVersions()
        {
            List <CompilerVersion> versions = new List <CompilerVersion>();

            if (DotnetDetection.IsDotnet35SP1Installed())
            {
                versions.Add(msbuild20);
                versions.Add(msbuild35);
            }
            versions.Add(msbuild40);
            return(versions);
        }
示例#4
0
        public void Initialize(ProjectOptionPanel projectOptions)
        {
            if (projectOptions == null)
            {
                throw new ArgumentNullException("projectOptions");
            }
            this.projectOptions = projectOptions;
            projectOptions.RegisterLoadSaveCallback(this);


            this.SerializationInfo = new List <KeyItemPair>();
            this.SerializationInfo.Add(new KeyItemPair("Off", StringParser.Parse("${res:Dialog.ProjectOptions.Build.Off}")));
            this.SerializationInfo.Add(new KeyItemPair("On", StringParser.Parse("${res:Dialog.ProjectOptions.Build.On}")));
            this.SerializationInfo.Add(new KeyItemPair("Auto", StringParser.Parse("${res:Dialog.ProjectOptions.Build.Auto}")));

            this.TargetCPU         = new List <KeyItemPair>();
            supports32BitPreferred = false;
            if (DotnetDetection.IsDotnet45Installed())
            {
                var upgradableProject = projectOptions.Project as IUpgradableProject;
                if (upgradableProject != null && upgradableProject.CurrentTargetFramework.IsBasedOn(TargetFramework.Net45))
                {
                    supports32BitPreferred = projectOptions.Project.MinimumSolutionVersion >= Solution.SolutionVersionVS2010;
                }
                // Show 32 vs. 64 options even for library projects;
                // it's relevant for web applications.
            }
            if (supports32BitPreferred)
            {
                this.TargetCPU.Add(new KeyItemPair("AnyCPU32", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any32}")));
                this.TargetCPU.Add(new KeyItemPair("AnyCPU64", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any64}")));
            }
            else
            {
                this.TargetCPU.Add(new KeyItemPair("AnyCPU", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any}")));
            }
            this.TargetCPU.Add(new KeyItemPair("x86", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x86}")));
            this.TargetCPU.Add(new KeyItemPair("x64", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x64}")));
            this.TargetCPU.Add(new KeyItemPair("Itanium", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Itanium}")));

            this.FileAlign = new List <KeyItemPair>();
            this.FileAlign.Add(new KeyItemPair("512", "512"));
            this.FileAlign.Add(new KeyItemPair("1024", "1024"));
            this.FileAlign.Add(new KeyItemPair("2048", "2048"));
            this.FileAlign.Add(new KeyItemPair("4096", "4096"));
            this.FileAlign.Add(new KeyItemPair("8192", "8192"));
        }
示例#5
0
        static bool CheckEnvironment()
        {
            // Safety check: our setup already checks that .NET 4 is installed, but we manually check the .NET version in case SharpDevelop is
            // used on another machine than it was installed on (e.g. "SharpDevelop on USB stick")
            if (!DotnetDetection.IsDotnet45Installed())
            {
                MessageBox.Show("This version of SharpDevelop requires .NET 4.5. You are using: " + Environment.Version, "SharpDevelop");
                return(false);
            }
            // Work around a WPF issue when %WINDIR% is set to an incorrect path
            string windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows, Environment.SpecialFolderOption.DoNotVerify);

            if (Environment.GetEnvironmentVariable("WINDIR") != windir)
            {
                Environment.SetEnvironmentVariable("WINDIR", windir);
            }
            return(true);
        }
        public void GetTypeInheritanceTreeOfClassDerivingFromListOfString()
        {
            if (DotnetDetection.IsDotnet45Installed())
            {
                Assert.Ignore(".NET 4.5 adds IReadOnlyList");
            }
            List <string> results = new List <IReturnType>(
                MemberLookupHelper.GetTypeInheritanceTree(CreateClassDerivingFromListOfString().DefaultReturnType)
                ).ConvertAll <string>(delegate(IReturnType rt) { return(rt.DotNetName); });

            results.Sort();             // order is not guaranteed, so sort for the unit test

            Assert.AreEqual("DerivesFromList;" +
                            "System.Collections.Generic.ICollection{System.String};" +
                            "System.Collections.Generic.IEnumerable{System.String};" +
                            "System.Collections.Generic.IList{System.String};" +
                            "System.Collections.Generic.List{System.String};" +
                            "System.Collections.ICollection;" +
                            "System.Collections.IEnumerable;" +
                            "System.Collections.IList;" +
                            "System.Object",
                            string.Join(";", results.ToArray()));
        }
        internal Task <bool> RunBuildAsync(CancellationToken cancellationToken)
        {
            Dictionary <string, string> globalProperties = new Dictionary <string, string>();

            globalProperties.AddRange(SD.MSBuildEngine.GlobalBuildProperties);

            foreach (KeyValuePair <string, string> pair in options.Properties)
            {
                LoggingService.Debug("Setting property " + pair.Key + " to '" + pair.Value + "'");
                globalProperties[pair.Key] = pair.Value;
            }
            globalProperties["Configuration"] = options.Configuration;
            if (options.Platform == "Any CPU")
            {
                globalProperties["Platform"] = "AnyCPU";
            }
            else
            {
                globalProperties["Platform"] = options.Platform;
            }

            InterestingTasks.AddRange(parentBuildEngine.CompileTaskNames);

            loggers.Add(new SharpDevelopLogger(this));
            if (options.BuildOutputVerbosity == BuildOutputVerbosity.Diagnostic)
            {
                this.ReportMessageEvents         = true;
                this.ReportAllTaskFinishedEvents = true;
                this.ReportAllTaskStartedEvents  = true;
                this.ReportTargetFinishedEvents  = true;
                this.ReportTargetStartedEvents   = true;
                this.ReportUnknownEvents         = true;
                loggers.Add(new SDConsoleLogger(feedbackSink, LoggerVerbosity.Diagnostic));
                globalProperties["MSBuildTargetsVerbose"] = "true";
            }
            //loggers.Add(new BuildLogFileLogger(project.FileName + ".log", LoggerVerbosity.Diagnostic));
            foreach (IMSBuildAdditionalLogger loggerProvider in parentBuildEngine.AdditionalMSBuildLoggers)
            {
                loggers.Add(loggerProvider.CreateLogger(this));
            }

            loggerChain = new EndOfChain(this);
            foreach (IMSBuildLoggerFilter loggerFilter in parentBuildEngine.MSBuildLoggerFilters)
            {
                loggerChain = loggerFilter.CreateFilter(this, loggerChain) ?? loggerChain;
            }

            WriteAdditionalTargetsToTempFile(globalProperties);

            BuildJob job = new BuildJob();

            job.ProjectFileName = projectFileName;
            job.Target          = options.Target.TargetName;

            // First remove the flags for the controllable events.
            job.EventMask = EventTypes.All & ~ControllableEvents;
            // Add back active controllable events.
            if (ReportMessageEvents)
            {
                job.EventMask |= EventTypes.Message;
            }
            if (ReportTargetStartedEvents)
            {
                job.EventMask |= EventTypes.TargetStarted;
            }
            if (ReportTargetFinishedEvents)
            {
                job.EventMask |= EventTypes.TargetFinished;
            }
            if (ReportAllTaskStartedEvents)
            {
                job.EventMask |= EventTypes.TaskStarted;
            }
            if (ReportAllTaskFinishedEvents)
            {
                job.EventMask |= EventTypes.TaskFinished;
            }
            if (ReportUnknownEvents)
            {
                job.EventMask |= EventTypes.Unknown;
            }

            if (!(ReportAllTaskStartedEvents && ReportAllTaskFinishedEvents))
            {
                // just some TaskStarted & TaskFinished events should be reported
                job.InterestingTaskNames.AddRange(InterestingTasks);
            }
            foreach (var pair in globalProperties)
            {
                job.Properties.Add(pair.Key, pair.Value);
            }

            foreach (ILogger logger in loggers)
            {
                logger.Initialize(eventSource);
            }

            tcs = new TaskCompletionSource <bool>();
            if (projectMinimumSolutionVersion <= SolutionFormatVersion.VS2008)
            {
                if (DotnetDetection.IsDotnet35SP1Installed())
                {
                    BuildWorkerManager.MSBuild35.RunBuildJob(job, loggerChain, OnDone, cancellationToken);
                }
                else
                {
                    loggerChain.HandleError(new BuildError(job.ProjectFileName, ".NET 3.5 SP1 is required to build this project."));
                    tcs.SetResult(false);
                }
            }
            else
            {
                BuildWorkerManager.MSBuild40.RunBuildJob(job, loggerChain, OnDone, cancellationToken);
            }
            return(tcs.Task);
        }
示例#8
0
 /// <summary>
 /// Debugger Tests currently require .NET 4.6
 /// </summary>
 protected static bool IsRuntimeCompatible()
 {
     return(DotnetDetection.IsDotnet46Installed());
 }
 public override bool IsAvailable()
 {
     // .NET 2.0/3.0/3.5 can only be used if .NET 3.5 SP1 is installed
     return(DotnetDetection.IsDotnet35SP1Installed());
 }