public CSharpProject(Solution solution, string title, string fileName)
		{
			this.Solution = solution;
			this.Title = title;
			this.FileName = fileName;
			
			var p = new Microsoft.Build.Evaluation.Project(fileName);
			this.AssemblyName = p.GetPropertyValue("AssemblyName");
			this.CompilerSettings.AllowUnsafeBlocks = GetBoolProperty(p, "AllowUnsafeBlocks") ?? false;
			this.CompilerSettings.CheckForOverflow = GetBoolProperty(p, "CheckForOverflowUnderflow") ?? false;
			foreach (string symbol in p.GetPropertyValue("DefineConstants").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) {
				this.CompilerSettings.ConditionalSymbols.Add(symbol.Trim());
			}
			foreach (var item in p.GetItems("Compile")) {
				Files.Add(new CSharpFile(this, Path.Combine(p.DirectoryPath, item.EvaluatedInclude)));
			}
			List<IAssemblyReference> references = new List<IAssemblyReference>();
			string mscorlib = FindAssembly(Program.AssemblySearchPaths, "mscorlib");
			if (mscorlib != null) {
				references.Add(Program.LoadAssembly(mscorlib));
			} else {
				Console.WriteLine("Could not find mscorlib");
			}
			bool hasSystemCore = false;
			foreach (var item in p.GetItems("Reference")) {
				string assemblyFileName = null;
				if (item.HasMetadata("HintPath")) {
					assemblyFileName = Path.Combine(p.DirectoryPath, item.GetMetadataValue("HintPath"));
					if (!File.Exists(assemblyFileName))
						assemblyFileName = null;
				}
				if (assemblyFileName == null) {
					assemblyFileName = FindAssembly(Program.AssemblySearchPaths, item.EvaluatedInclude);
				}
				if (assemblyFileName != null) {
					if (Path.GetFileName(assemblyFileName).Equals("System.Core.dll", StringComparison.OrdinalIgnoreCase))
						hasSystemCore = true;
					references.Add(Program.LoadAssembly(assemblyFileName));
				} else {
					Console.WriteLine("Could not find referenced assembly " + item.EvaluatedInclude);
				}
			}
			if (!hasSystemCore && FindAssembly(Program.AssemblySearchPaths, "System.Core") != null)
				references.Add(Program.LoadAssembly(FindAssembly(Program.AssemblySearchPaths, "System.Core")));
			foreach (var item in p.GetItems("ProjectReference")) {
				references.Add(new ProjectReference(solution, item.GetMetadataValue("Name")));
			}
			this.ProjectContent = new CSharpProjectContent()
				.SetAssemblyName(this.AssemblyName)
				.SetCompilerSettings(this.CompilerSettings)
				.AddAssemblyReferences(references)
				.UpdateProjectContent(null, Files.Select(f => f.ParsedFile));
		}
Beispiel #2
0
		public CSharpProject(Solution solution, string title, string fileName)
		{
			// Normalize the file name
			fileName = Path.GetFullPath(fileName);
			
			this.Solution = solution;
			this.Title = title;
			this.FileName = fileName;
			
			// Use MSBuild to open the .csproj
			var msbuildProject = new Microsoft.Build.Evaluation.Project(fileName);
			// Figure out some compiler settings
			this.AssemblyName = msbuildProject.GetPropertyValue("AssemblyName");
			this.CompilerSettings.AllowUnsafeBlocks = GetBoolProperty(msbuildProject, "AllowUnsafeBlocks") ?? false;
			this.CompilerSettings.CheckForOverflow = GetBoolProperty(msbuildProject, "CheckForOverflowUnderflow") ?? false;
			string defineConstants = msbuildProject.GetPropertyValue("DefineConstants");
			foreach (string symbol in defineConstants.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
				this.CompilerSettings.ConditionalSymbols.Add(symbol.Trim());
			
			// Initialize the unresolved type system
			IProjectContent pc = new CSharpProjectContent();
			pc = pc.SetAssemblyName(this.AssemblyName);
			pc = pc.SetProjectFileName(fileName);
			pc = pc.SetCompilerSettings(this.CompilerSettings);
			// Parse the C# code files
			foreach (var item in msbuildProject.GetItems("Compile")) {
				var file = new CSharpFile(this, Path.Combine(msbuildProject.DirectoryPath, item.EvaluatedInclude));
				Files.Add(file);
			}
			// Add parsed files to the type system
			pc = pc.AddOrUpdateFiles(Files.Select(f => f.UnresolvedTypeSystemForFile));
			
			// Add referenced assemblies:
			foreach (string assemblyFile in ResolveAssemblyReferences(msbuildProject)) {
				IUnresolvedAssembly assembly = solution.LoadAssembly(assemblyFile);
				pc = pc.AddAssemblyReferences(new [] { assembly });
			}
			
			// Add project references:
			foreach (var item in msbuildProject.GetItems("ProjectReference")) {
				string referencedFileName = Path.Combine(msbuildProject.DirectoryPath, item.EvaluatedInclude);
				// Normalize the path; this is required to match the name with the referenced project's file name
				referencedFileName = Path.GetFullPath(referencedFileName);
				pc = pc.AddAssemblyReferences(new[] { new ProjectReference(referencedFileName) });
			}
			this.ProjectContent = pc;
		}
Beispiel #3
0
        public async Task <string> TryGetOutputFilePathAsync(
            string path, IDictionary <string, string> globalProperties, CancellationToken cancellationToken)
        {
            // This tries to get the project output path and retrieving the $(TargetPath) property.

            var(project, _) = await LoadProjectAsync(path, globalProperties, cancellationToken).ConfigureAwait(false);

            return(project?.GetPropertyValue(PropertyNames.TargetPath));
        }
Beispiel #4
0
        public async Task <string?> TryGetOutputFilePathAsync(
            string path, CancellationToken cancellationToken)
        {
            Debug.Assert(_batchBuildStarted);

            // This tries to get the project output path and retrieving the evaluated $(TargetPath) property.

            var(project, _) = await LoadProjectAsync(path, cancellationToken).ConfigureAwait(false);

            return(project?.GetPropertyValue(PropertyNames.TargetPath));
        }
Beispiel #5
0
        /// <summary>
        /// Toes the hierarchy.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <returns></returns>
        public static IVsHierarchy ToHierarchy(EnvDTE.Project project)
        {
            if (project == null) throw new ArgumentNullException("project");

            // DTE does not expose the project GUID that exists at in the msbuild project file.
            Microsoft.Build.Evaluation.Project msproject = new Microsoft.Build.Evaluation.Project();
            msproject.FullPath = project.FileName;
            
            string guid = msproject.GetPropertyValue("ProjectGuid");

            IServiceProvider serviceProvider = new ServiceProvider(project.DTE as
                Microsoft.VisualStudio.OLE.Interop.IServiceProvider);

            return VsShellUtilities.GetHierarchy(serviceProvider, new Guid(guid));
        }
        /// <summary>
        /// The resolved type system for this project.
        /// This field is initialized once all projects have been loaded (in Solution constructor).
        /// </summary>
        public CSharpProject(Solution solution, string title, string fileName)
        {
            // Normalize the file name
            fileName = Path.GetFullPath(fileName);

            this.Solution = solution;
            this.Title = title;
            this.FileName = fileName;

            // Use MSBuild to open the .csproj
            var msbuildProject = new Microsoft.Build.Evaluation.Project(fileName);
            // Figure out some compiler settings
            this.AssemblyName = msbuildProject.GetPropertyValue("AssemblyName");

            // Parse the C# code files
            foreach (var item in msbuildProject.GetItems("Compile"))
            {
                var file = new CSharpFile(this, Path.Combine(msbuildProject.DirectoryPath, item.EvaluatedInclude));
                Files.Add(file);
            }
        }
        public void SolutionConfigurationWithDependencies()
        {
            string solutionFileContents =
                @"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 11
Project(`{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}`) = `A`, `Project1\A.csproj`, `{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}`
EndProject
Project(`{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}`) = `B`, `Project2\B.csproj`, `{881C1674-4ECA-451D-85B6-D7C59B7F16FA}`
	ProjectSection(ProjectDependencies) = postProject
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167} = {4A727FF8-65F2-401E-95AD-7C8BBFBE3167}
	EndProjectSection
EndProject
Project(`{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}`) = `C`, `Project3\C.csproj`, `{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}`
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Debug|x64 = Debug|x64
		Release|Any CPU = Release|Any CPU
		Release|x64 = Release|x64
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = preSolution
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Debug|x64.ActiveCfg = Debug|Any CPU
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Debug|x64.Build.0 = Debug|Any CPU
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Release|Any CPU.Build.0 = Release|Any CPU
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Release|x64.ActiveCfg = Release|Any CPU
		{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}.Release|x64.Build.0 = Release|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Debug|x64.ActiveCfg = Debug|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Debug|x64.Build.0 = Debug|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Release|Any CPU.Build.0 = Release|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Release|x64.ActiveCfg = Release|Any CPU
		{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}.Release|x64.Build.0 = Release|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Debug|x64.ActiveCfg = Debug|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Debug|x64.Build.0 = Debug|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Release|Any CPU.Build.0 = Release|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Release|x64.ActiveCfg = Release|Any CPU
		{881C1674-4ECA-451D-85B6-D7C59B7F16FA}.Release|x64.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal
".Replace("`", "\"");

            SolutionFile solution = SolutionFile_Tests.ParseSolutionHelper(solutionFileContents);

            ProjectRootElement projectXml = ProjectRootElement.Create();

            foreach (SolutionConfigurationInSolution solutionConfiguration in solution.SolutionConfigurations)
            {
                SolutionProjectGenerator.AddPropertyGroupForSolutionConfiguration(projectXml, solution, solutionConfiguration);
            }

            Project msbuildProject = new Project(projectXml);

            // Both projects configurations should be present for solution configuration "Debug|Mixed Platforms"
            msbuildProject.SetGlobalProperty("Configuration", "Debug");
            msbuildProject.SetGlobalProperty("Platform", "Any CPU");
            msbuildProject.ReevaluateIfNecessary();

            string solutionConfigurationContents = msbuildProject.GetPropertyValue("CurrentSolutionConfigurationContents");

            // Only the specified solution configuration is represented in THE BLOB: nothing for x64 in this case
            string expected = @"<SolutionConfiguration>
  <ProjectConfiguration Project=`{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}` AbsolutePath=`##temp##Project1\A.csproj` BuildProjectInSolution=`True`>Debug|AnyCPU</ProjectConfiguration>
  <ProjectConfiguration Project=`{881C1674-4ECA-451D-85B6-D7C59B7F16FA}` AbsolutePath=`##temp##Project2\B.csproj` BuildProjectInSolution=`True`>Debug|AnyCPU<ProjectDependency Project=`{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}` /></ProjectConfiguration>
  <ProjectConfiguration Project=`{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}` AbsolutePath=`##temp##Project3\C.csproj` BuildProjectInSolution=`True`>Debug|AnyCPU</ProjectConfiguration>
</SolutionConfiguration>".Replace("`", "\"").Replace("##temp##", Path.GetTempPath());

            Helpers.VerifyAssertLineByLine(expected, solutionConfigurationContents);
        }
Beispiel #8
0
        public CSharpProject(ISolution solution,
                             IFileSystem fileSystem,
                             Logger logger, 
                             string title, 
                             string fileName, 
                             Guid id)
            : base(fileSystem, logger)
        {
            _fileSystem = fileSystem;
            _logger = logger;
            _solution = solution;
            Title = title;
            if (fileSystem is FileSystem)
            {
                fileName = fileName.ForceNativePathSeparator();
            }
            FileName = fileName;
            ProjectId = id;
            Files = new List<CSharpFile>();
            Microsoft.Build.Evaluation.Project project;

            try
            {
                project = new Microsoft.Build.Evaluation.Project(_fileSystem, fileName);
            }
            catch (DirectoryNotFoundException)
            {
                logger.Error("Directory not found - " + FileName);
                return;
            }
            catch (FileNotFoundException)
            {
                logger.Error("File not found - " + FileName);
                return;
            }

            AssemblyName = project.GetPropertyValue("AssemblyName");

            SetCompilerSettings(project);

            AddCSharpFiles(project);

            References = new List<IAssemblyReference>();
            this.ProjectContent = new CSharpProjectContent()
                .SetAssemblyName(AssemblyName)
                .AddOrUpdateFiles(Files.Select(f => f.ParsedFile));

            AddMsCorlib();

            bool hasSystemCore = false;
            foreach (var item in project.GetItems("Reference"))
            {
                var assemblyFileName = GetAssemblyFileNameFromHintPath(project, item);
                //If there isn't a path hint or it doesn't exist, try searching
                if (assemblyFileName == null)
                    assemblyFileName = FindAssembly(item.EvaluatedInclude);

                //If it isn't in the search paths, try the GAC
                if (assemblyFileName == null && PlatformService.IsWindows)
                    assemblyFileName = FindAssemblyInNetGac(item.EvaluatedInclude);

                if (assemblyFileName != null)
                {
                    if (_fileSystem.Path.GetFileName(assemblyFileName).Equals("System.Core.dll", StringComparison.OrdinalIgnoreCase))
                        hasSystemCore = true;

                    _logger.Debug("Loading assembly " + item.EvaluatedInclude);
                    try
                    {
                        AddReference(LoadAssembly(assemblyFileName));
                    }
                    catch (Exception e)
                    {
                        _logger.Error(e);
                    }

                }
                else
                    _logger.Error("Could not find referenced assembly " + item.EvaluatedInclude);
            }
            if (!hasSystemCore && FindAssembly("System.Core") != null)
                AddReference(LoadAssembly(FindAssembly("System.Core")));

            AddProjectReferences(project);
        }
        public CSharpProject(ISolution solution, string title, string fileName, Guid id)
        {
            _solution = solution;
            Title = title;
            FileName = fileName.ForceNativePathSeparator();
            ProjectId = id;
            Files = new List<CSharpFile>();

            var p = new Microsoft.Build.Evaluation.Project(FileName);
            AssemblyName = p.GetPropertyValue("AssemblyName");

            _compilerSettings = new CompilerSettings
                {
                    AllowUnsafeBlocks = GetBoolProperty(p, "AllowUnsafeBlocks") ?? false,
                    CheckForOverflow = GetBoolProperty(p, "CheckForOverflowUnderflow") ?? false,
                };
            string[] defines = p.GetPropertyValue("DefineConstants").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string define in defines)
                _compilerSettings.ConditionalSymbols.Add(define);

            foreach (var item in p.GetItems("Compile"))
            {
                try
                {
                    string path = Path.Combine(p.DirectoryPath, item.EvaluatedInclude).ForceNativePathSeparator();
                    if (File.Exists(path))
                    {
                        Files.Add(new CSharpFile(this, new FileInfo(path).FullName));
                    }
                    else
                    {
                        Console.WriteLine("File does not exist - " + path);
                    }
                }
                catch (NullReferenceException e)
                {
                    Console.WriteLine(e);
                }
            }

            References = new List<IAssemblyReference>();
            string mscorlib = FindAssembly(AssemblySearchPaths, "mscorlib");
            if (mscorlib != null)
                AddReference(LoadAssembly(mscorlib));
            else
                Console.WriteLine("Could not find mscorlib");

            bool hasSystemCore = false;
            foreach (var item in p.GetItems("Reference"))
            {

                string assemblyFileName = null;
                if (item.HasMetadata("HintPath"))
                {
                    assemblyFileName = Path.Combine(p.DirectoryPath, item.GetMetadataValue("HintPath")).ForceNativePathSeparator();
                    if (!File.Exists(assemblyFileName))
                        assemblyFileName = null;
                }
                //If there isn't a path hint or it doesn't exist, try searching
                if (assemblyFileName == null)
                    assemblyFileName = FindAssembly(AssemblySearchPaths, item.EvaluatedInclude);

                //If it isn't in the search paths, try the GAC
                if (assemblyFileName == null)
                    assemblyFileName = FindAssemblyInNetGac(item.EvaluatedInclude);

                if (assemblyFileName != null)
                {
                    if (Path.GetFileName(assemblyFileName).Equals("System.Core.dll", StringComparison.OrdinalIgnoreCase))
                        hasSystemCore = true;

                    Console.WriteLine("Loading assembly " + item.EvaluatedInclude);
                    try
                    {
                        AddReference(LoadAssembly(assemblyFileName));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                }
                else
                    Console.WriteLine("Could not find referenced assembly " + item.EvaluatedInclude);
            }
            if (!hasSystemCore && FindAssembly(AssemblySearchPaths, "System.Core") != null)
                AddReference(LoadAssembly(FindAssembly(AssemblySearchPaths, "System.Core")));

            foreach (var item in p.GetItems("ProjectReference"))
                AddReference(new ProjectReference(_solution, item.GetMetadataValue("Name")));

            this.ProjectContent = new CSharpProjectContent()
                .SetAssemblyName(AssemblyName)
                .AddAssemblyReferences(References)
                .AddOrUpdateFiles(Files.Select(f => f.ParsedFile));
        }
Beispiel #10
0
            public static ProjectData Create(MSB.Evaluation.Project project)
            {
                var guid                   = PropertyConverter.ToGuid(project.GetPropertyValue(PropertyNames.ProjectGuid));
                var name                   = project.GetPropertyValue(PropertyNames.ProjectName);
                var assemblyName           = project.GetPropertyValue(PropertyNames.AssemblyName);
                var targetPath             = project.GetPropertyValue(PropertyNames.TargetPath);
                var outputPath             = project.GetPropertyValue(PropertyNames.OutputPath);
                var intermediateOutputPath = project.GetPropertyValue(PropertyNames.IntermediateOutputPath);
                var projectAssetsFile      = project.GetPropertyValue(PropertyNames.ProjectAssetsFile);
                var configuration          = project.GetPropertyValue(PropertyNames.Configuration);
                var platform               = project.GetPropertyValue(PropertyNames.Platform);
                var defaultNamespace       = project.GetPropertyValue(PropertyNames.RootNamespace);

                var targetFramework = new FrameworkName(project.GetPropertyValue(PropertyNames.TargetFrameworkMoniker));

                var targetFrameworkValue = project.GetPropertyValue(PropertyNames.TargetFramework);
                var targetFrameworks     = PropertyConverter.SplitList(project.GetPropertyValue(PropertyNames.TargetFrameworks), ';');

                if (!string.IsNullOrWhiteSpace(targetFrameworkValue) && targetFrameworks.Length == 0)
                {
                    targetFrameworks = ImmutableArray.Create(targetFrameworkValue);
                }

                var languageVersion           = PropertyConverter.ToLanguageVersion(project.GetPropertyValue(PropertyNames.LangVersion));
                var allowUnsafeCode           = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.AllowUnsafeBlocks), defaultValue: false);
                var checkForOverflowUnderflow = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.CheckForOverflowUnderflow), defaultValue: false);
                var outputKind                     = PropertyConverter.ToOutputKind(project.GetPropertyValue(PropertyNames.OutputType));
                var nullableContextOptions         = PropertyConverter.ToNullableContextOptions(project.GetPropertyValue(PropertyNames.Nullable));
                var documentationFile              = project.GetPropertyValue(PropertyNames.DocumentationFile);
                var preprocessorSymbolNames        = PropertyConverter.ToPreprocessorSymbolNames(project.GetPropertyValue(PropertyNames.DefineConstants));
                var suppressedDiagnosticIds        = PropertyConverter.ToSuppressedDiagnosticIds(project.GetPropertyValue(PropertyNames.NoWarn));
                var warningsAsErrors               = PropertyConverter.SplitList(project.GetPropertyValue(PropertyNames.WarningsAsErrors), ',');
                var warningsNotAsErrors            = PropertyConverter.SplitList(project.GetPropertyValue(PropertyNames.WarningsNotAsErrors), ',');
                var signAssembly                   = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.SignAssembly), defaultValue: false);
                var assemblyOriginatorKeyFile      = project.GetPropertyValue(PropertyNames.AssemblyOriginatorKeyFile);
                var treatWarningsAsErrors          = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.TreatWarningsAsErrors), defaultValue: false);
                var runAnalyzers                   = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.RunAnalyzers), defaultValue: true);
                var runAnalyzersDuringLiveAnalysis = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.RunAnalyzersDuringLiveAnalysis), defaultValue: true);

                return(new ProjectData(
                           guid, name, assemblyName, targetPath, outputPath, intermediateOutputPath, projectAssetsFile,
                           configuration, platform, targetFramework, targetFrameworks, outputKind, languageVersion, nullableContextOptions, allowUnsafeCode, checkForOverflowUnderflow,
                           documentationFile, preprocessorSymbolNames, suppressedDiagnosticIds, warningsAsErrors, warningsNotAsErrors, signAssembly, assemblyOriginatorKeyFile, treatWarningsAsErrors, defaultNamespace, runAnalyzers, runAnalyzersDuringLiveAnalysis, ruleset: null));
            }
        /// <summary>
        /// Loads each MSBuild project in this solution and looks for its project-to-project references so that
        /// we know what build order we should use when building the solution. 
        /// </summary>
        private void ScanProjectDependencies(string childProjectToolsVersion, string fullSolutionConfigurationName)
        {
            // Don't bother with all this if the solution configuration doesn't even exist.
            if (fullSolutionConfigurationName == null)
            {
                return;
            }

            foreach (ProjectInSolution project in _solutionFile.ProjectsInOrder)
            {
                // We only need to scan .wdproj projects: Everything else is either MSBuildFormat or 
                // something we don't know how to do anything with anyway
                if (project.ProjectType == SolutionProjectType.WebDeploymentProject)
                {
                    // Skip the project if we don't have its configuration in this solution configuration
                    if (!project.ProjectConfigurations.ContainsKey(fullSolutionConfigurationName))
                    {
                        continue;
                    }

                    try
                    {
                        Project msbuildProject = new Project(project.AbsolutePath, _globalProperties, childProjectToolsVersion);

                        // ProjectDependency items work exactly like ProjectReference items from the point of 
                        // view of determining that project B depends on project A.  This item must cause
                        // project A to be built prior to project B.
                        //
                        // This has the format 
                        // <ProjectDependency Include="DependentProjectRelativePath">
                        //   <Project>{GUID}</Project>
                        // </Project>
                        IEnumerable<ProjectItem> references = msbuildProject.GetItems("ProjectDependency");

                        foreach (ProjectItem reference in references)
                        {
                            string referencedProjectGuid = reference.GetMetadataValue("Project");
                            AddDependencyByGuid(project, referencedProjectGuid);
                        }

                        // If this is a web deployment project, we have a reference specified as a property
                        // "SourceWebProject" rather than as a ProjectReference item.  This has the format
                        // {GUID}|PATH_TO_CSPROJ
                        // where
                        // GUID is the project guid for the "source" project
                        // PATH_TO_CSPROJ is the solution-relative path to the csproj file.
                        //
                        // NOTE: This is obsolete and is intended only for backward compatability with
                        // Whidbey-generated web deployment projects.  New projects should use the
                        // ProjectDependency item above.
                        string referencedWebProjectGuid = msbuildProject.GetPropertyValue("SourceWebProject");
                        if (!string.IsNullOrEmpty(referencedWebProjectGuid))
                        {
                            // Grab the guid with its curly braces...
                            referencedWebProjectGuid = referencedWebProjectGuid.Substring(0, 38);
                            AddDependencyByGuid(project, referencedWebProjectGuid);
                        }
                    }
                    catch (Exception e)
                    {
                        // We don't want any problems scanning the project file to result in aborting the build.
                        if (ExceptionHandling.IsCriticalException(e))
                        {
                            throw;
                        }

                        _loggingService.LogWarning
                            (
                            _projectBuildEventContext,
                            "SubCategoryForSolutionParsingErrors",
                            new BuildEventFileInfo(project.RelativePath),
                            "SolutionScanProjectDependenciesFailed",
                            project.RelativePath,
                            e.Message
                            );
                    }
                }
            }
        }
Beispiel #12
0
 public string GetPropertyValue(string name)
 {
     return(_loadedProject.GetPropertyValue(name));
 }
Beispiel #13
0
        public bool BuildProjectAndGetOutputZips(BuildOptions options, out FileInfo[] installPackages, out DTE dte)
        {
            // Get an instance of the currently running Visual Studio IDE.
            installPackages = null;
            dte             = null;
            string dteObjectString   = string.Format("VisualStudio.DTE.{0}", options.EnvDteVersion);
            string runningObjectName = string.Format("!{0}:{1}", dteObjectString, options.ProcessId);

            var runningObjects            = RunningObjectsTable.GetRunningObjects();
            var visualStudioRunningObject = runningObjects.FirstOrDefault(r => r.name == runningObjectName);

            if (visualStudioRunningObject.o == null)
            {
                _Logger.LogError(string.Format("Unable to find Visual Studio instance: {0}. Ensure if VS is running as Admin, then DnnPackager.exe should also be executed from Admin elevated process otherwise it won't find VS. It's also possible DnnPackager.exe doesn't support your visual studio version yet.. Please raise an issue on GitHub.", runningObjectName));
                foreach (var item in runningObjects)
                {
                    _Logger.LogInfo(string.Format("running object name: {0}", item.name));
                }
                return(false);
            }

            dte = (EnvDTE.DTE)visualStudioRunningObject.o;

            // Register the IOleMessageFilter to handle any threading errors as per: https://msdn.microsoft.com/en-us/library/ms228772(v=vs.100).aspx
            MessageFilter.Register();

            string configurationName = dte.Solution.SolutionBuild.ActiveConfiguration.Name;

            if (string.IsNullOrWhiteSpace(options.Configuration))
            {
                configurationName = options.Configuration;
            }

            //  dte.Solution.SolutionBuild.Build(true);
            var projects = dte.Solution.Projects;
            var project  = projects.OfType <EnvDTE.Project>().FirstOrDefault(p => p.Name == options.ProjectName);

            if (project == null)
            {
                _Logger.LogError(string.Format("Unable to find project named: {0}.", options.ProjectName));
                return(false);
            }

            var fullName = project.FullName;

            dte.Solution.SolutionBuild.BuildProject(configurationName, fullName, true);

            // now get output zips
            installPackages = GetProjectOutputZips(project, configurationName);

            // now filter based on whether we want to install the sources or normal install package.
            Microsoft.Build.Evaluation.ProjectCollection collection     = new Microsoft.Build.Evaluation.ProjectCollection();
            Microsoft.Build.Evaluation.Project           msBuildProject = new Microsoft.Build.Evaluation.Project(project.FullName, null, null, collection, Microsoft.Build.Evaluation.ProjectLoadSettings.IgnoreMissingImports);


            if (options.Sources)
            {
                string sourceszipSuffix = msBuildProject.GetPropertyValue("DnnSourcesZipFileSuffix");
                installPackages =
                    installPackages.Where(a => Path.GetFileNameWithoutExtension(a.Name).ToLowerInvariant().EndsWith(sourceszipSuffix.ToLowerInvariant()))
                    .ToArray();
            }
            else
            {
                string installzipSuffix = msBuildProject.GetPropertyValue("DnnInstallZipFileSuffix");
                installPackages =
                    installPackages.Where(a => Path.GetFileNameWithoutExtension(a.Name).ToLowerInvariant().EndsWith(installzipSuffix.ToLowerInvariant()))
                    .ToArray();
            }

            return(true);
        }
Beispiel #14
0
        public CSharpProject(ISolution solution, Logger logger, string title, string fileName, Guid id)
        {
            _logger   = logger;
            _solution = solution;
            Title     = title;
            FileName  = fileName.ForceNativePathSeparator();
            ProjectId = id;
            Files     = new List <CSharpFile>();
            Microsoft.Build.Evaluation.Project project;

            try
            {
                project = new Microsoft.Build.Evaluation.Project(FileName);
            }
            catch (DirectoryNotFoundException)
            {
                logger.Error("Directory not found - " + FileName);
                return;
            }

            AssemblyName = project.GetPropertyValue("AssemblyName");

            SetCompilerSettings(project);

            AddCSharpFiles(project);

            References          = new List <IAssemblyReference>();
            this.ProjectContent = new CSharpProjectContent()
                                  .SetAssemblyName(AssemblyName)
                                  .AddOrUpdateFiles(Files.Select(f => f.ParsedFile));

            AddMsCorlib();

            bool hasSystemCore = false;

            foreach (var item in project.GetItems("Reference"))
            {
                var assemblyFileName = GetAssemblyFileNameFromHintPath(project, item);
                //If there isn't a path hint or it doesn't exist, try searching
                if (assemblyFileName == null)
                {
                    assemblyFileName = FindAssembly(item.EvaluatedInclude);
                }

                //If it isn't in the search paths, try the GAC
                if (assemblyFileName == null && PlatformService.IsWindows)
                {
                    assemblyFileName = FindAssemblyInNetGac(item.EvaluatedInclude);
                }

                if (assemblyFileName != null)
                {
                    if (Path.GetFileName(assemblyFileName).Equals("System.Core.dll", StringComparison.OrdinalIgnoreCase))
                    {
                        hasSystemCore = true;
                    }

                    _logger.Debug("Loading assembly " + item.EvaluatedInclude);
                    try
                    {
                        AddReference(LoadAssembly(assemblyFileName));
                    }
                    catch (Exception e)
                    {
                        _logger.Error(e);
                    }
                }
                else
                {
                    _logger.Error("Could not find referenced assembly " + item.EvaluatedInclude);
                }
            }
            if (!hasSystemCore && FindAssembly("System.Core") != null)
            {
                AddReference(LoadAssembly(FindAssembly("System.Core")));
            }


            AddProjectReferences(project);
        }
        public void TestAddPropertyGroupForSolutionConfiguration()
        {
            string solutionFileContents =
                @"
                Microsoft Visual Studio Solution File, Format Version 9.00
                # Visual Studio 2005
                Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'ClassLibrary1', 'ClassLibrary1\ClassLibrary1.csproj', '{6185CC21-BE89-448A-B3C0-D1C27112E595}'
                EndProject
                Project('{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}') = 'MainApp', 'MainApp\MainApp.vcxproj', '{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}'
                EndProject
                Global
                    GlobalSection(SolutionConfigurationPlatforms) = preSolution
                        Debug|Mixed Platforms = Debug|Mixed Platforms
                        Release|Any CPU = Release|Any CPU
                    EndGlobalSection
                    GlobalSection(ProjectConfigurationPlatforms) = postSolution
                        {6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Mixed Platforms.ActiveCfg = CSConfig1|Any CPU
                        {6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Mixed Platforms.Build.0 = CSConfig1|Any CPU
                        {6185CC21-BE89-448A-B3C0-D1C27112E595}.Release|Any CPU.ActiveCfg = CSConfig2|Any CPU
                        {A6F99D27-47B9-4EA4-BFC9-25157CBDC281}.Debug|Mixed Platforms.ActiveCfg = VCConfig1|Win32
                        {A6F99D27-47B9-4EA4-BFC9-25157CBDC281}.Debug|Mixed Platforms.Build.0 = VCConfig1|Win32
                    EndGlobalSection
                EndGlobal
                ";

            SolutionFile solution = SolutionFile_Tests.ParseSolutionHelper(solutionFileContents);

            ProjectRootElement projectXml = ProjectRootElement.Create();

            foreach (SolutionConfigurationInSolution solutionConfiguration in solution.SolutionConfigurations)
            {
                SolutionProjectGenerator.AddPropertyGroupForSolutionConfiguration(projectXml, solution, solutionConfiguration);
            }

            Project msbuildProject = new Project(projectXml);

            // Both projects configurations should be present for solution configuration "Debug|Mixed Platforms"
            msbuildProject.SetGlobalProperty("Configuration", "Debug");
            msbuildProject.SetGlobalProperty("Platform", "Mixed Platforms");
            msbuildProject.ReevaluateIfNecessary();

            string solutionConfigurationContents = msbuildProject.GetPropertyValue("CurrentSolutionConfigurationContents");
            string tempProjectPath = Path.Combine(Path.GetTempPath(), "ClassLibrary1\\ClassLibrary1.csproj");

            Assert.IsTrue(solutionConfigurationContents.Contains("{6185CC21-BE89-448A-B3C0-D1C27112E595}"));
            tempProjectPath = Path.GetFullPath(tempProjectPath);
            Assert.IsTrue(solutionConfigurationContents.IndexOf(tempProjectPath, StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(solutionConfigurationContents.Contains("CSConfig1|AnyCPU"));

            tempProjectPath = Path.Combine(Path.GetTempPath(), "MainApp\\MainApp.vcxproj");
            tempProjectPath = Path.GetFullPath(tempProjectPath);
            Assert.IsTrue(solutionConfigurationContents.Contains("{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}"));
            Assert.IsTrue(solutionConfigurationContents.IndexOf(tempProjectPath, StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(solutionConfigurationContents.Contains("VCConfig1|Win32"));

            // Only the C# project should be present for solution configuration "Release|Any CPU", since the VC project
            // is missing
            msbuildProject.SetGlobalProperty("Configuration", "Release");
            msbuildProject.SetGlobalProperty("Platform", "Any CPU");
            msbuildProject.ReevaluateIfNecessary();

            solutionConfigurationContents = msbuildProject.GetPropertyValue("CurrentSolutionConfigurationContents");

            Assert.IsTrue(solutionConfigurationContents.Contains("{6185CC21-BE89-448A-B3C0-D1C27112E595}"));
            Assert.IsTrue(solutionConfigurationContents.Contains("CSConfig2|AnyCPU"));

            Assert.IsFalse(solutionConfigurationContents.Contains("{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}"));
        }
        public void TestAddPropertyGroupForSolutionConfigurationBuildProjectInSolutionNotSet()
        {
            string solutionFileContents =
                @"
                Microsoft Visual Studio Solution File, Format Version 9.00
                # Visual Studio 2005
                Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'ClassLibrary1', 'ClassLibrary1\ClassLibrary1.csproj', '{6185CC21-BE89-448A-B3C0-D1C27112E595}'
                EndProject
                Global
                    GlobalSection(SolutionConfigurationPlatforms) = preSolution
                        Debug|Mixed Platforms = Debug|Mixed Platforms
                        Release|Any CPU = Release|Any CPU
                    EndGlobalSection
                     GlobalSection(ProjectConfigurationPlatforms) = postSolution
                        {6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Mixed Platforms.ActiveCfg = CSConfig1|Any CPU
                    EndGlobalSection
                EndGlobal
                ";

            SolutionFile solution = SolutionFile_Tests.ParseSolutionHelper(solutionFileContents);

            ProjectRootElement projectXml = ProjectRootElement.Create();

            foreach (SolutionConfigurationInSolution solutionConfiguration in solution.SolutionConfigurations)
            {
                SolutionProjectGenerator.AddPropertyGroupForSolutionConfiguration(projectXml, solution, solutionConfiguration);
            }

            Project msbuildProject = new Project(projectXml);

            // Both projects configurations should be present for solution configuration "Debug|Mixed Platforms"
            msbuildProject.SetGlobalProperty("Configuration", "Debug");
            msbuildProject.SetGlobalProperty("Platform", "Mixed Platforms");
            msbuildProject.ReevaluateIfNecessary();

            string solutionConfigurationContents = msbuildProject.GetPropertyValue("CurrentSolutionConfigurationContents");
            Assert.IsTrue(solutionConfigurationContents.Contains(@"BuildProjectInSolution=""" + bool.FalseString + @""""));
        }
            public static ProjectData Create(MSB.Evaluation.Project project)
            {
                var guid              = PropertyConverter.ToGuid(project.GetPropertyValue(PropertyNames.ProjectGuid));
                var name              = project.GetPropertyValue(PropertyNames.ProjectName);
                var assemblyName      = project.GetPropertyValue(PropertyNames.AssemblyName);
                var targetPath        = project.GetPropertyValue(PropertyNames.TargetPath);
                var outputPath        = project.GetPropertyValue(PropertyNames.OutputPath);
                var projectAssetsFile = project.GetPropertyValue(PropertyNames.ProjectAssetsFile);

                var targetFramework = new FrameworkName(project.GetPropertyValue(PropertyNames.TargetFrameworkMoniker));

                var targetFrameworkValue = project.GetPropertyValue(PropertyNames.TargetFramework);
                var targetFrameworks     = PropertyConverter.SplitList(project.GetPropertyValue(PropertyNames.TargetFrameworks), ';');

                if (!string.IsNullOrWhiteSpace(targetFrameworkValue) && targetFrameworks.Length == 0)
                {
                    targetFrameworks = ImmutableArray.Create(targetFrameworkValue);
                }

                var languageVersion           = PropertyConverter.ToLanguageVersion(project.GetPropertyValue(PropertyNames.LangVersion));
                var allowUnsafeCode           = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.AllowUnsafeBlocks), defaultValue: false);
                var outputKind                = PropertyConverter.ToOutputKind(project.GetPropertyValue(PropertyNames.OutputType));
                var documentationFile         = project.GetPropertyValue(PropertyNames.DocumentationFile);
                var preprocessorSymbolNames   = PropertyConverter.ToPreprocessorSymbolNames(project.GetPropertyValue(PropertyNames.DefineConstants));
                var suppressedDiagnosticIds   = PropertyConverter.ToSuppressedDiagnosticIds(project.GetPropertyValue(PropertyNames.NoWarn));
                var signAssembly              = PropertyConverter.ToBoolean(project.GetPropertyValue(PropertyNames.SignAssembly), defaultValue: false);
                var assemblyOriginatorKeyFile = project.GetPropertyValue(PropertyNames.AssemblyOriginatorKeyFile);

                return(new ProjectData(
                           guid, name, assemblyName, targetPath, outputPath, projectAssetsFile,
                           targetFramework, targetFrameworks, outputKind, languageVersion, allowUnsafeCode,
                           documentationFile, preprocessorSymbolNames, suppressedDiagnosticIds, signAssembly, assemblyOriginatorKeyFile));
            }
 private static void SetMsBuildProjectProperty(MsBuildProject buildProject, string name, string value)
 {
     if (!value.Equals(buildProject.GetPropertyValue(name), StringComparison.OrdinalIgnoreCase))
     {
         buildProject.SetProperty(name, value);
     }
 }
Beispiel #19
0
        public CSharpProject(ISolution solution, string title, string fileName, Guid id)
        {
            _solution = solution;
            Title     = title;
            FileName  = fileName.ForceNativePathSeparator();
            ProjectId = id;
            Files     = new List <CSharpFile>();

            var p = new Microsoft.Build.Evaluation.Project(FileName);

            AssemblyName = p.GetPropertyValue("AssemblyName");

            _compilerSettings = new CompilerSettings
            {
                AllowUnsafeBlocks = GetBoolProperty(p, "AllowUnsafeBlocks") ?? false,
                CheckForOverflow  = GetBoolProperty(p, "CheckForOverflowUnderflow") ?? false,
            };
            string[] defines = p.GetPropertyValue("DefineConstants").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string define in defines)
            {
                _compilerSettings.ConditionalSymbols.Add(define);
            }

            foreach (var item in p.GetItems("Compile"))
            {
                try
                {
                    string path = Path.Combine(p.DirectoryPath, item.EvaluatedInclude).ForceNativePathSeparator();
                    if (File.Exists(path))
                    {
                        Files.Add(new CSharpFile(this, new FileInfo(path).FullName));
                    }
                    else
                    {
                        Console.WriteLine("File does not exist - " + path);
                    }
                }
                catch (NullReferenceException e)
                {
                    Console.WriteLine(e);
                }
            }

            References = new List <IAssemblyReference>();
            string mscorlib = FindAssembly(AssemblySearchPaths, "mscorlib");

            if (mscorlib != null)
            {
                AddReference(LoadAssembly(mscorlib));
            }
            else
            {
                Console.WriteLine("Could not find mscorlib");
            }

            bool hasSystemCore = false;

            foreach (var item in p.GetItems("Reference"))
            {
                string assemblyFileName = null;
                if (item.HasMetadata("HintPath"))
                {
                    assemblyFileName = Path.Combine(p.DirectoryPath, item.GetMetadataValue("HintPath")).ForceNativePathSeparator();
                    if (!File.Exists(assemblyFileName))
                    {
                        assemblyFileName = null;
                    }
                }
                //If there isn't a path hint or it doesn't exist, try searching
                if (assemblyFileName == null)
                {
                    assemblyFileName = FindAssembly(AssemblySearchPaths, item.EvaluatedInclude);
                }

                //If it isn't in the search paths, try the GAC
                if (assemblyFileName == null)
                {
                    assemblyFileName = FindAssemblyInNetGac(item.EvaluatedInclude);
                }

                if (assemblyFileName != null)
                {
                    if (Path.GetFileName(assemblyFileName).Equals("System.Core.dll", StringComparison.OrdinalIgnoreCase))
                    {
                        hasSystemCore = true;
                    }

                    Console.WriteLine("Loading assembly " + item.EvaluatedInclude);
                    try
                    {
                        AddReference(LoadAssembly(assemblyFileName));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else
                {
                    Console.WriteLine("Could not find referenced assembly " + item.EvaluatedInclude);
                }
            }
            if (!hasSystemCore && FindAssembly(AssemblySearchPaths, "System.Core") != null)
            {
                AddReference(LoadAssembly(FindAssembly(AssemblySearchPaths, "System.Core")));
            }

            foreach (var item in p.GetItems("ProjectReference"))
            {
                var projectName   = item.GetMetadataValue("Name");
                var referenceGuid = Guid.Parse(item.GetMetadataValue("Project"));
                Console.WriteLine("Adding project reference {0}, {1}", projectName, referenceGuid);
                AddReference(new ProjectReference(_solution, projectName, referenceGuid));
            }

            this.ProjectContent = new CSharpProjectContent()
                                  .SetAssemblyName(AssemblyName)
                                  .AddAssemblyReferences(References)
                                  .AddOrUpdateFiles(Files.Select(f => f.ParsedFile));
        }
        /// <summary>
        /// Retrives the list of project guids from the project file.
        /// If you don't want your project to be flavorable, override
        /// to only return your project factory Guid:
        ///      return this.GetType().GUID.ToString("B");
        /// </summary>
        /// <param name="file">Project file to look into to find the Guid list</param>
        /// <returns>List of semi-colon separated GUIDs</returns>
        protected override string ProjectTypeGuids(string file)
        {
            // Load the project so we can extract the list of GUIDs

            this.buildProject = Utilities.ReinitializeMsBuildProject(this.buildEngine, file, this.buildProject);

            // Retrieve the list of GUIDs, if it is not specify, make it our GUID
            string guids = buildProject.GetPropertyValue(ProjectFileConstants.ProjectTypeGuids);
            if (String.IsNullOrEmpty(guids))
                guids = this.GetType().GUID.ToString("B");

            return guids;
        }
        public CSharpProject(Solution solution, string title, string fileName)
        {
            this.Solution = solution;
            this.Title    = title;
            this.FileName = fileName;

            var p = new Microsoft.Build.Evaluation.Project(fileName);

            this.AssemblyName              = p.GetPropertyValue("AssemblyName");
            this.AllowUnsafeBlocks         = GetBoolProperty(p, "AllowUnsafeBlocks") ?? false;
            this.CheckForOverflowUnderflow = GetBoolProperty(p, "CheckForOverflowUnderflow") ?? false;
            this.PreprocessorDefines       = p.GetPropertyValue("DefineConstants").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in p.GetItems("Compile"))
            {
                Files.Add(new CSharpFile(this, Path.Combine(p.DirectoryPath, item.EvaluatedInclude)));
            }
            List <IAssemblyReference> references = new List <IAssemblyReference>();
            string mscorlib = FindAssembly(Program.AssemblySearchPaths, "mscorlib");

            if (mscorlib != null)
            {
                references.Add(Program.LoadAssembly(mscorlib));
            }
            else
            {
                Console.WriteLine("Could not find mscorlib");
            }
            bool hasSystemCore = false;

            foreach (var item in p.GetItems("Reference"))
            {
                string assemblyFileName = null;
                if (item.HasMetadata("HintPath"))
                {
                    assemblyFileName = Path.Combine(p.DirectoryPath, item.GetMetadataValue("HintPath"));
                    if (!File.Exists(assemblyFileName))
                    {
                        assemblyFileName = null;
                    }
                }
                if (assemblyFileName == null)
                {
                    assemblyFileName = FindAssembly(Program.AssemblySearchPaths, item.EvaluatedInclude);
                }
                if (assemblyFileName != null)
                {
                    if (Path.GetFileName(assemblyFileName).Equals("System.Core.dll", StringComparison.OrdinalIgnoreCase))
                    {
                        hasSystemCore = true;
                    }
                    references.Add(Program.LoadAssembly(assemblyFileName));
                }
                else
                {
                    Console.WriteLine("Could not find referenced assembly " + item.EvaluatedInclude);
                }
            }
            if (!hasSystemCore && FindAssembly(Program.AssemblySearchPaths, "System.Core") != null)
            {
                references.Add(Program.LoadAssembly(FindAssembly(Program.AssemblySearchPaths, "System.Core")));
            }
            foreach (var item in p.GetItems("ProjectReference"))
            {
                references.Add(new ProjectReference(solution, item.GetMetadataValue("Name")));
            }
            this.ProjectContent = new CSharpProjectContent()
                                  .SetAssemblyName(this.AssemblyName)
                                  .AddAssemblyReferences(references)
                                  .UpdateProjectContent(null, Files.Select(f => f.ParsedFile));
        }