// Internal for testing
        internal static bool TryGetConfiguration(
            IMSBuildEvaluatedPropertyCollection projectProperties,
            IEnumerable <IMSBuildItemEvaluated> projectItems,
            out RazorConfiguration configuration)
        {
            if (!TryGetDefaultConfiguration(projectProperties, out var defaultConfiguration))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetLanguageVersion(projectProperties, out var languageVersion))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetConfigurationItem(defaultConfiguration, projectItems, out var configurationItem))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetConfiguredExtensionNames(configurationItem, out var configuredExtensionNames))
            {
                configuration = null;
                return(false);
            }

            var extensions = GetExtensions(configuredExtensionNames, projectItems);

            configuration = new ProjectSystemRazorConfiguration(languageVersion, configurationItem.Include, extensions);
            return(true);
        }
        internal protected virtual void Read(IMSBuildEvaluatedPropertyCollection pset, string toolsVersion)
        {
            evaluatedProperties = pset;

            intermediateOutputDirectory = pset.GetPathValue("IntermediateOutputPath");
            outputDirectory             = pset.GetPathValue("OutputPath", defaultValue: "." + Path.DirectorySeparatorChar);
            debugMode             = pset.GetValue <bool> ("DebugSymbols", false);
            pauseConsoleOutput    = pset.GetValue("ConsolePause", true);
            externalConsole       = pset.GetValue <bool> ("ExternalConsole");
            commandLineParameters = pset.GetValue("Commandlineparameters", "");
            runWithWarnings       = pset.GetValue("RunWithWarnings", true);

            // Special case: when DebugType=none, xbuild returns an empty string
            debugType = pset.GetValue("DebugType");
            if (string.IsNullOrEmpty(debugType))
            {
                debugType            = "none";
                debugTypeReadAsEmpty = true;
            }
            debugTypeWasNone = debugType == "none";

            var svars = pset.GetValue("EnvironmentVariables");

            ParseEnvironmentVariables(svars, environmentVariables);

            // Kep a clone of the loaded env vars, so we can check if they have changed when saving
            loadedEnvironmentVariables = new Dictionary <string, string> (environmentVariables);

            pset.ReadObjectProperties(this, GetType(), true);
        }
		internal protected virtual void Read (IMSBuildEvaluatedPropertyCollection pset, string toolsVersion)
		{
			evaluatedProperties = pset;

			intermediateOutputDirectory = pset.GetPathValue ("IntermediateOutputPath");
			outputDirectory = pset.GetPathValue ("OutputPath", defaultValue:"." + Path.DirectorySeparatorChar);
			debugMode = pset.GetValue<bool> ("DebugSymbols", false);
			pauseConsoleOutput = pset.GetValue ("ConsolePause", true);
			externalConsole = pset.GetValue<bool> ("ExternalConsole");
			commandLineParameters = pset.GetValue ("Commandlineparameters", "");
			runWithWarnings = pset.GetValue ("RunWithWarnings", true);

			// Special case: when DebugType=none, xbuild returns an empty string
			debugType = pset.GetValue ("DebugType");
			if (string.IsNullOrEmpty (debugType)) {
				debugType = "none";
				debugTypeReadAsEmpty = true;
			}
			debugTypeWasNone = debugType == "none";

			var svars = pset.GetValue ("EnvironmentVariables");
			ParseEnvironmentVariables (svars, environmentVariables);

			// Kep a clone of the loaded env vars, so we can check if they have changed when saving
			loadedEnvironmentVariables = new Dictionary<string, string> (environmentVariables);
			
			pset.ReadObjectProperties (this, GetType (), true);
		}
        // Internal for testing
        internal static bool TryGetDefaultConfiguration(IMSBuildEvaluatedPropertyCollection projectProperties, out string defaultConfiguration)
        {
            defaultConfiguration = projectProperties.GetValue(RazorDefaultConfigurationProperty);
            if (string.IsNullOrEmpty(defaultConfiguration))
            {
                defaultConfiguration = null;
                return(false);
            }

            return(true);
        }
        // Internal for testing
        internal static bool TryGetRootNamespace(IMSBuildEvaluatedPropertyCollection projectProperties, out string rootNamespace)
        {
            rootNamespace = projectProperties.GetValue(RootNamespaceProperty);
            if (string.IsNullOrEmpty(rootNamespace))
            {
                rootNamespace = null;
                return false;
            }

            return true;
        }
        // Internal for testing
        internal static bool TryGetLanguageVersion(IMSBuildEvaluatedPropertyCollection projectProperties, out RazorLanguageVersion languageVersion)
        {
            var languageVersionValue = projectProperties.GetValue(RazorLangVersionProperty);
            if (string.IsNullOrEmpty(languageVersionValue))
            {
                languageVersion = null;
                return false;
            }

            if (!RazorLanguageVersion.TryParse(languageVersionValue, out languageVersion))
            {
                languageVersion = RazorLanguageVersion.Latest;
            }

            return true;
        }
        internal protected override void Read(IMSBuildEvaluatedPropertyCollection pset, string toolsVersion)
        {
            base.Read(pset, toolsVersion);

            assembly        = pset.GetValue("AssemblyName");
            signAssembly    = pset.GetValue <bool> ("SignAssembly");
            delaySign       = pset.GetValue <bool> ("DelaySign");
            assemblyKeyFile = pset.GetPathValue("AssemblyOriginatorKeyFile", FilePath.Empty);
            if (string.IsNullOrEmpty(assemblyKeyFile))
            {
                assemblyKeyFile = pset.GetPathValue("AssemblyKeyFile", FilePath.Empty);
            }
            if (compilationParameters != null)
            {
                compilationParameters.Read(pset, toolsVersion);
            }
        }
        protected override void Read(IMSBuildEvaluatedPropertyCollection pset, string toolsVersion)
        {
            base.Read(pset, toolsVersion);

            var prop = pset.GetProperty("GenerateDocumentation");

            if (prop != null && documentationFile != null)
            {
                if (prop.GetValue <bool> ())
                {
                    documentationFile = ParentConfiguration.CompiledOutputName.ChangeExtension(".xml");
                }
                else
                {
                    documentationFile = null;
                }
            }

            optimize = pset.GetValue("Optimize", (bool?)null);
        }
		internal protected virtual void Read (IMSBuildEvaluatedPropertyCollection pset, string toolsVersion)
		{
			pset.ReadObjectProperties (this, GetType (), true);
		}
		protected override void Read (IMSBuildEvaluatedPropertyCollection pset, string toolsVersion)
		{
			base.Read (pset, toolsVersion);

			var prop = pset.GetProperty ("GenerateDocumentation");
			if (prop != null && documentationFile != null) {
				if (prop.GetValue<bool> ())
					documentationFile = ParentConfiguration.CompiledOutputName.ChangeExtension (".xml");
				else
					documentationFile = null;
			}

			optimize = pset.GetValue ("Optimize", (bool?)null);
		}
		protected override void OnReadConfiguration (ProgressMonitor monitor, ProjectConfiguration config, IMSBuildEvaluatedPropertyCollection pset)
		{
			base.OnReadConfiguration (monitor, config, pset);

			// Backwards compatibility. Move parameters to the project parameters object

			var prop = pset.GetProperty ("ApplicationIcon");
			if (prop != null)
				win32Icon = prop.GetPathValue ();

			prop = pset.GetProperty ("Win32Resource");
			if (prop != null)
				win32Resource = prop.GetPathValue ();

			prop = pset.GetProperty ("StartupObject");
			if (prop != null)
				mainclass = prop.Value;

			prop = pset.GetProperty ("CodePage");
			if (prop != null)
				codePage = int.Parse (prop.Value);
		}
		internal protected virtual void OnReadConfiguration (ProgressMonitor monitor, ProjectConfiguration config, IMSBuildEvaluatedPropertyCollection pset)
		{
			next.OnReadConfiguration (monitor, config, pset);
		}
Example #13
0
        protected override void OnReadConfiguration(ProgressMonitor monitor, ProjectConfiguration config, IMSBuildEvaluatedPropertyCollection pset)
        {
            base.OnReadConfiguration(monitor, config, pset);

            // Backwards compatibility. Move parameters to the project parameters object

            var prop = pset.GetProperty("ApplicationIcon");

            if (prop != null)
            {
                win32Icon = prop.GetPathValue();
            }

            prop = pset.GetProperty("Win32Resource");
            if (prop != null)
            {
                win32Resource = prop.GetPathValue();
            }

            prop = pset.GetProperty("StartupObject");
            if (prop != null)
            {
                mainclass = prop.Value;
            }

            prop = pset.GetProperty("CodePage");
            if (prop != null)
            {
                codePage = int.Parse(prop.Value);
            }
        }
Example #14
0
 internal protected virtual void Read(IMSBuildEvaluatedPropertyCollection pset, string toolsVersion)
 {
     pset.ReadObjectProperties(this, GetType(), true);
 }
 internal protected virtual void OnReadConfiguration(ProgressMonitor monitor, ProjectConfiguration config, IMSBuildEvaluatedPropertyCollection pset)
 {
     next.OnReadConfiguration(monitor, config, pset);
 }