• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Evaluation.Project类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Build.Evaluation.Project的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Build.Evaluation.Project类的具体用法?C# Microsoft.Build.Evaluation.Project怎么用?C# Microsoft.Build.Evaluation.Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Microsoft.Build.Evaluation.Project类属于命名空间,在下文中一共展示了Microsoft.Build.Evaluation.Project类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CSharpProject

		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));
		}
开发者ID:mono-soc-2012,项目名称:NRefactory,代码行数:53,代码来源:CSharpProject.cs


示例2: AddEnsureImportedTarget

        private static void AddEnsureImportedTarget(MsBuildProject buildProject, string targetsPath)
        {
            // get the target
            var targetElement = buildProject.Xml.Targets.FirstOrDefault(
                target => target.Name.Equals(targetName, StringComparison.OrdinalIgnoreCase));

            // if the target does not exist, create the target
            if (targetElement == null)
            {
                targetElement = buildProject.Xml.AddTarget(targetName);

                // PrepareForBuild is used here because BeforeBuild does not work for VC++ projects.
                targetElement.BeforeTargets = "PrepareForBuild";

                var propertyGroup = targetElement.AddPropertyGroup();
                propertyGroup.AddProperty("ErrorText", CommonResources.EnsureImportedMessage);
            }

            var errorTask = targetElement.AddTask("Error");
            errorTask.Condition = "!Exists('" + targetsPath + "')";
            var errorText = string.Format(
                CultureInfo.InvariantCulture,
                @"$([System.String]::Format('$(ErrorText)', '{0}'))",
                targetsPath);
            errorTask.SetParameter("Text", errorText);
        }
开发者ID:tomgrv,项目名称:PA.InnoSetupProcessor,代码行数:26,代码来源:MsBuildProjectUtility.cs


示例3: CreateFromProject

        public static ActionsModule CreateFromProject(string projectFile, string outputFile, LightningDevelopmentHandle lightningDevelopmentHandle)
        {
            var engine = new Microsoft.Build.Evaluation.Project(projectFile);
            engine.Build();

            return CreateFromDll(outputFile, lightningDevelopmentHandle);
        }
开发者ID:mhgamework,项目名称:LightningDevelopment,代码行数:7,代码来源:ActionsModule.cs


示例4: BasicTests

 public BasicTests(ITestOutputHelper logger)
 {
     this.logger = logger;
     this.nuproj = Assets.FromTemplate()
                         .AssignNuProjDirectory()
                         .ToProject();
 }
开发者ID:kovalikp,项目名称:nuproj,代码行数:7,代码来源:BasicTests.cs


示例5: AddNewErrorWarningMessageElement

        public void AddNewErrorWarningMessageElement()
        {
            MockLogger logger = new MockLogger();

            /**
             * <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
             *   <Target Name=`Build`>
             *   </Target>
             * </Project
             */

            ProjectRootElement projectXml = ProjectRootElement.Create();
            ProjectTargetElement target = projectXml.AddTarget("Build");
            projectXml.DefaultTargets = "Build";
            projectXml.ToolsVersion = ObjectModelHelpers.MSBuildDefaultToolsVersion;

            SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.message, true, "SolutionVenusProjectNoClean");
            SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.warning, true, "SolutionParseUnknownProjectType", "proj1.csproj");
            SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.error, true, "SolutionInvalidSolutionConfiguration");

            Project project = new Project(projectXml);

            project.Build(logger);

            string code = null;
            string keyword = null;
            string text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionParseUnknownProjectType", "proj1.csproj");

            // check the error event
            Assert.AreEqual(1, logger.Warnings.Count);
            BuildWarningEventArgs warning = logger.Warnings[0];

            Assert.AreEqual(text, warning.Message);
            Assert.AreEqual(code, warning.Code);
            Assert.AreEqual(keyword, warning.HelpKeyword);

            code = null;
            keyword = null;
            text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionInvalidSolutionConfiguration");

            // check the warning event
            Assert.AreEqual(1, logger.Errors.Count);
            BuildErrorEventArgs error = logger.Errors[0];

            Assert.AreEqual(text, error.Message);
            Assert.AreEqual(code, error.Code);
            Assert.AreEqual(keyword, error.HelpKeyword);

            code = null;
            keyword = null;
            text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionVenusProjectNoClean");

            // check the message event
            Assert.IsTrue(logger.FullLog.Contains(text), "Log should contain the regular message");
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:55,代码来源:SolutionProjectGenerator_Tests.cs


示例6: AddFeatureFileLinkToIntelliSenseProject

 private static void AddFeatureFileLinkToIntelliSenseProject(string featureFilePath, string featureDir, string pathToIntelliSenseProject)
 {
     _csProj = _csProj ?? GetUnloadedProject(pathToIntelliSenseProject);
     featureFilePath = MakeLinkRelativeToIntelliSenseProject(featureFilePath, featureDir);
     var featureFileLink = featureFilePath.Replace(@"..\", string.Empty);
     if (!_csProj.Items.Any(item => item.GetMetadataValue("Link") == featureFileLink))
     {
         _csProj.AddItem("None", featureFilePath, new Dictionary<string, string> { { "Link", featureFileLink } });
         _isDirtyCsProj = true;
     }
 }
开发者ID:SCRUMdifferent,项目名称:specflowC,代码行数:11,代码来源:Program.cs


示例7: Build

 /// <summary>
 /// Builds this project, using the default targets and the given loggers.
 /// </summary>
 /// <param name="loggers">An enumerator over all loggers to be used during the build.</param>
 /// <returns>
 /// Returns true on success; false otherwise.
 /// </returns>
 public bool Build(IEnumerable<ILogger> loggers)
 {
     var result = false;
     this.SwapMSBuildTasks();
     using (var reader = this.Document.CreateReader())
     {
         reader.MoveToContent();
         var innerProject = new Microsoft.Build.Evaluation.Project(reader);
         result = innerProject.Build(loggers.Prepend(this.Logger));
         reader.Close();
     }
     return result;
 }
开发者ID:slpsys,项目名称:BuildSniffer,代码行数:20,代码来源:Project.cs


示例8: AddFilesToCppProject

        private static void AddFilesToCppProject(string pathToFile, string featureDir, string pathToCppProject)
        {
            _cppProj = _cppProj ?? GetUnloadedProject(pathToCppProject);

            pathToFile = MakeFeatureDirRelativeToCppProject(pathToFile, featureDir);

            string type = CppFileType(pathToFile);

            if (!_cppProj.GetItems(type).Any(item => item.UnevaluatedInclude == pathToFile))
            {
                _cppProj.AddItem(type, pathToFile);
                _isDirtyCppProj = true;
            }
        }
开发者ID:SCRUMdifferent,项目名称:specflowC,代码行数:14,代码来源:Program.cs


示例9: ToHierarchy

        /// <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));
        }
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:20,代码来源:VsHelper.cs


示例10: ConfigProjectImport

        private static void ConfigProjectImport(Project project, string targetRelativePath, string configTransformTargetFile)
        {
            // clear out any existing value
            var importPathMSBuildProperty = "ConfigTransformTargetPath";
            var msbuildProp = project.Xml.Properties.Where(x => x.Name == importPathMSBuildProperty).ToArray();
            msbuildProp.Delete();

            // creates a property to store the target file path
            var importPath = $"$({importPathMSBuildProperty})\\{configTransformTargetFile}";
            project.Xml.AddProperty(importPathMSBuildProperty, targetRelativePath);

            // create import element with exists condition and add as last project import
            var importXmlElement = project.Xml.CreateImportElement(importPath);
            importXmlElement.Condition = $"Exists('{importPath}')";
            project.Xml.InsertAfterChild(importXmlElement, project.Xml.Imports.Last());
        }
开发者ID:matt40k,项目名称:VSAutomate,代码行数:16,代码来源:AppConfigTransform.cs


示例11: RemoveImportStatement

        /// <summary>
        /// Removes the Import element from the project file.
        /// </summary>
        /// <param name="project">The project file.</param>
        /// <param name="targetsPath">The path to the imported file.</param>
        public static void RemoveImportStatement(MsBuildProject project, string targetsPath)
        {
            if (project.Xml.Imports != null)
            {
                // search for this import statement and remove it
                var importElement = project.Xml.Imports.FirstOrDefault(
                    import => targetsPath.Equals(import.Project, StringComparison.OrdinalIgnoreCase));

                if (importElement != null)
                {
                    importElement.Parent.RemoveChild(importElement);
                    NuGet.MSBuildProjectUtility.RemoveEnsureImportedTarget(project, targetsPath);
                    project.ReevaluateIfNecessary();
                }
            }
        }
开发者ID:tomgrv,项目名称:PA.InnoSetupProcessor,代码行数:21,代码来源:MsBuildProjectUtility.cs


示例12: CSharpProject

		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;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:47,代码来源:CSharpProject.cs


示例13: AddImportStatement

        /// <summary>
        /// Adds an Import element to this project file if it doesn't already exist.            
        /// </summary>
        /// <param name="project">The project file.</param>
        /// <param name="targetsPath">The path to the imported file.</param>
        /// <param name="location">The location where the Import is added.</param>
        public static void AddImportStatement(MsBuildProject project, string targetsPath, ProjectImportLocation location)
        {
            if (project.Xml.Imports == null ||
                project.Xml.Imports.All(import => !targetsPath.Equals(import.Project, StringComparison.OrdinalIgnoreCase)))
            {
                ProjectImportElement pie = project.Xml.AddImport(targetsPath);
                pie.Condition = "Exists('" + targetsPath + "')";
                if (location == ProjectImportLocation.Top)
                {
                    // There's no public constructor to create a ProjectImportElement directly.
                    // So we have to cheat by adding Import at the end, then remove it and insert at the beginning
                    pie.Parent.RemoveChild(pie);
                    project.Xml.InsertBeforeChild(pie, project.Xml.FirstChild);
                }

                NuGet.MSBuildProjectUtility.AddEnsureImportedTarget(project, targetsPath);
                project.ReevaluateIfNecessary();
            }
        }
开发者ID:tomgrv,项目名称:PA.InnoSetupProcessor,代码行数:25,代码来源:MsBuildProjectUtility.cs


示例14: CSharpProject

        /// <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);
            }
        }
开发者ID:gitexperience,项目名称:ClassDiagramNR6,代码行数:25,代码来源:CSharpProject.cs


示例15: RemoveEnsureImportedTarget

        public static void RemoveEnsureImportedTarget(MsBuildProject buildProject, string targetsPath)
        {
            var targetElement = buildProject.Xml.Targets.FirstOrDefault(
                target => string.Equals(target.Name, targetName, StringComparison.OrdinalIgnoreCase));
            if (targetElement == null)
            {
                return;
            }

            string errorCondition = "!Exists('" + targetsPath + "')";
            var taskElement = targetElement.Tasks.FirstOrDefault(
                task => string.Equals(task.Condition, errorCondition, StringComparison.OrdinalIgnoreCase));
            if (taskElement == null)
            {
                return;
            }

            taskElement.Parent.RemoveChild(taskElement);
            if (targetElement.Tasks.Count == 0)
            {
                targetElement.Parent.RemoveChild(targetElement);
            }
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:23,代码来源:MsBuildProjectUtility.cs


示例16: RestoreConfigurationProperty

        // This method is to restore the property value with old one when configuration goes wrong.
        // Unlike SetConfigurationProperty(), this method won't reevaluate the project prior to add the value, which may raise exceptions. 
        private void RestoreConfigurationProperty(string propertyName, string propertyValue)
        {
            string condition = this.configCanonicalName.ToMSBuildCondition();
            // Get properties for current configuration from project file and cache it
            MSBuildProject.SetGlobalProperty(this.project.BuildProject, ProjectFileConstants.Configuration, configCanonicalName.ConfigName);
            MSBuildProject.SetGlobalProperty(this.project.BuildProject, ProjectFileConstants.Platform, configCanonicalName.MSBuildPlatform);

            this.evaluatedProject = this.project.BuildProject;

            SetPropertyUnderConditionImpl(propertyName, propertyValue, condition);
            this.evaluatedProject = null;
            UpdateOutputGroup();                
        }
开发者ID:dedale,项目名称:visualfsharp,代码行数:15,代码来源:ProjectConfig.cs


示例17: ScanProjectDependencies

        /// <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
                            );
                    }
                }
            }
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:83,代码来源:SolutionProjectGenerator.cs


示例18: EnsureCache

 private void EnsureCache()
 {
     // Get properties for current configuration from project file and cache it
     this.project.SetConfiguration(configCanonicalName);
     this.evaluatedProject = this.project.BuildProject;
     // REVIEW: The call below will set the Project configuration to the Solution configuration
     // for the purpose of evaluating properties - this is exactly what we don't want to do.
     // Can anyone think of a reason why we'd want to keep it?
     //project.SetCurrentConfiguration();
 }
开发者ID:dedale,项目名称:visualfsharp,代码行数:10,代码来源:ProjectConfig.cs


示例19: SetConfigurationProperty

        public virtual void SetConfigurationProperty(string propertyName, string propertyValue)
        {
            if (!this.project.QueryEditProjectFile(false))
            {
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            string condition = this.configCanonicalName.ToMSBuildCondition();
            SetPropertyUnderCondition(propertyName, propertyValue, condition);

            // property cache will need to be updated
            this.evaluatedProject = null;
            UpdateOutputGroup();                
        }
开发者ID:dedale,项目名称:visualfsharp,代码行数:14,代码来源:ProjectConfig.cs


示例20: AddSolutionDirProperty

        private void AddSolutionDirProperty(MsBuildProject buildProject)
        {
            const string solutiondir = "SolutionDir";

            if (buildProject.Xml.Properties == null ||
                buildProject.Xml.Properties.All(p => p.Name != solutiondir))
            {
                string relativeSolutionPath = PathUtility.GetRelativePath(
                    buildProject.FullPath,
                    PathUtility.EnsureTrailingSlash(_solutionManager.SolutionDirectory));
                relativeSolutionPath = PathUtility.EnsureTrailingSlash(relativeSolutionPath);

                var solutionDirProperty = buildProject.Xml.AddProperty(solutiondir, relativeSolutionPath);
                solutionDirProperty.Condition =
                    String.Format(
                        CultureInfo.InvariantCulture,
                        @"$({0}) == '' Or $({0}) == '*Undefined*'",
                        solutiondir);
            }
        }
开发者ID:Mailaender,项目名称:xamarin-nuget,代码行数:20,代码来源:PackageRestoreManager.cs



注:本文中的Microsoft.Build.Evaluation.Project类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.CSharpCodeProvider类代码示例发布时间:2022-05-24
下一篇:
C# Build.Evaluation类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap