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

C# UnitTests.MockLogger类代码示例

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

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



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

示例1: Initialize

 public void Initialize()
 {
     engine = new Engine();
     myProject = new Project(engine);
     myLogger = new MockLogger();
     myProject.ParentEngine.RegisterLogger(myLogger);
 }
开发者ID:nikson,项目名称:msbuild,代码行数:7,代码来源:TargetCollection_Tests.cs


示例2: ImportFromExtensionsPathNotFound

        public void ImportFromExtensionsPathNotFound()
        {
            string extnDir1 = null;
            string mainProjectPath = null;

            try {
                extnDir1 = GetNewExtensionsPathAndCreateFile("extensions1", Path.Combine("foo", "extn.proj"), GetExtensionTargetsFileContent1());
                mainProjectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("main.proj", GetMainTargetFileContent());

                var projColln = new ProjectCollection();
                projColln.ResetToolsetsForTests(WriteConfigFileAndGetReader("MSBuildExtensionsPath", extnDir1, Path.Combine("tmp", "nonexistant")));
                var logger = new MockLogger();
                projColln.RegisterLogger(logger);

                Assert.Throws<InvalidProjectFileException>(() => projColln.LoadProject(mainProjectPath));

                logger.AssertLogContains("MSB4226");
            } finally {
                if (mainProjectPath != null)
                {
                    FileUtilities.DeleteNoThrow(mainProjectPath);
                }
                if (extnDir1 != null)
                {
                    FileUtilities.DeleteDirectoryNoThrow(extnDir1, recursive: true);
                }
            }
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:28,代码来源:ImportFromMSBuildExtensionsPath_Tests.cs


示例3: MockEngine

 public MockEngine(bool logToConsole)
 {
     mockLogger = new MockLogger();
     this.logToConsole = logToConsole;
     this.engine = new Engine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath));
     this.engine.RegisterLogger(new ConsoleLogger());
     this.engine.RegisterLogger(mockLogger);
     engineGlobalProperties = new BuildPropertyGroup();
 }
开发者ID:nikson,项目名称:msbuild,代码行数:9,代码来源:MockEngine.cs


示例4: Initialize

        public void Initialize()
        {
            ObjectModelHelpers.DeleteTempProjectDirectory();

            engine = new Engine();
            engine.DefaultToolsVersion = "4.0";
            project = new Project(engine);
            logger = new MockLogger();
            project.ParentEngine.RegisterLogger(logger);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:10,代码来源:BuildTask_Tests.cs


示例5: InvalidToolPath

        public void InvalidToolPath()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            Engine e = new Engine();
            MockLogger mockLogger = new MockLogger();
            e.RegisterLogger(mockLogger);
            ToolsetState t = new ToolsetState(e, new Toolset("toolsversionname", "invalid||path"), new GetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath));

            TaskRegistry taskRegistry = (TaskRegistry) t.GetTaskRegistry(null);

            Console.WriteLine(mockLogger.FullLog);
            Assert.AreEqual(1, mockLogger.WarningCount, "Expected a warning for invalid character in toolpath"); 
        }
开发者ID:nikson,项目名称:msbuild,代码行数:13,代码来源:ToolsVersion_Tests.cs


示例6: AddNewErrorWarningMessageElement

        public void AddNewErrorWarningMessageElement()
        {
            MockLogger logger = new MockLogger();
            Project project = ObjectModelHelpers.CreateInMemoryProject(
                "<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>" +
                    "<Target Name=`Build`>" +
                    "</Target>" +
                "</Project>",
                logger);

            Target target = project.Targets["Build"];

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

            project.Build(null, null);

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

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

            Assertion.AssertEquals(text, warning.Message);
            Assertion.AssertEquals(code, warning.Code);
            Assertion.AssertEquals(keyword, warning.HelpKeyword);

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

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

            Assertion.AssertEquals(text, error.Message);
            Assertion.AssertEquals(code, error.Code);
            Assertion.AssertEquals(keyword, error.HelpKeyword);

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

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


示例7: TargetARM

        public void TargetARM()
        {
            string file = null;
            string outputPath = Path.GetTempPath() + "\\" + Guid.NewGuid().ToString("N");

            try
            {
                file = Helpers.CreateFiles("class1.cs")[0];

                MockLogger logger = new MockLogger();

                Project project = ObjectModelHelpers.CreateInMemoryProject(
                    @"
                   <Project DefaultTargets=`Build` ToolsVersion=`4.0` xmlns=`msbuildnamespace`>
                      <PropertyGroup>
                        <OutputPath>" + outputPath + @"</OutputPath>
                        <AssemblyName>MyAssembly</AssemblyName>
                        <OutputType>Library</OutputType>
                        <Configuration>Debug</Configuration>
                        <PlatformTarget>arm</PlatformTarget>
                      </PropertyGroup>
                      <ItemGroup>
                        <Compile Include=`" + file + @"` />
                      </ItemGroup>
                      <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.Targets` />
                    </Project>
                ",
                 logger
                 );

                project.Build();

                logger.AssertLogContains(" /platform:arm ");
            }
            finally
            {
                if (file != null)
                {
                    File.Delete(file);
                }

                ObjectModelHelpers.DeleteDirectory(outputPath);
            }
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:44,代码来源:TargetsFile_Test.cs


示例8: WarningLoggedIfNoDefaultTasksFound

        public void WarningLoggedIfNoDefaultTasksFound()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            Engine e = new Engine();
            MockLogger mockLogger = new MockLogger();
            e.RegisterLogger(mockLogger);

            ToolsetState t = new ToolsetState(e, new Toolset("toolsversionname", "c:\\directory1\\directory2\\doesntexist"), new GetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath));

            TaskRegistry taskRegistry = (TaskRegistry) t.GetTaskRegistry(null);

            string[] unexpectedRegisteredTasks = { "a1", "a2", "a3", "a4", "b1", "c1", "d1", "e1", "f1", "g1", "g2", "g3", "11", "12", "13", "21" };

            Assert.AreEqual(1, mockLogger.WarningCount, "Expected 1 warning logged!");
            foreach (string unexpectedRegisteredTask in unexpectedRegisteredTasks)
            {
                Hashtable registeredTasks;
                Assert.IsFalse(taskRegistry.FindRegisteredTasks(unexpectedRegisteredTask, true, out registeredTasks),
                               String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:21,代码来源:ToolsVersion_Tests.cs


示例9: Basic

        public void Basic()
        {
            MockLogger l = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"

                <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`> 
                   <Target Name='CleanUp'>
                      <Message Text='CleanUp-was-called.'/>
                   </Target>
                   <Target Name='Build'>
                      <Error Text='This is an error.'/>
                      <OnError ExecuteTargets='CleanUp'/>
                   </Target>
                </Project>",
                l
            );

            p.Build(new string [] {"Build"}, null);

            Assertion.Assert("Expected one error because 'Build' failed.", l.ErrorCount==1);
            Assertion.Assert("The CleanUp target should have been called.", (l.FullLog.IndexOf("CleanUp-was-called") != -1));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:22,代码来源:OnError_Tests.cs


示例10: VerifyToolsetAndToolLocationHelperAgree

        public void VerifyToolsetAndToolLocationHelperAgree()
        {
            string projectContents = ObjectModelHelpers.CleanupFileContents(@"
                    <Project xmlns='msbuildnamespace' ToolsVersion='msbuilddefaulttoolsversion'>
                        <UsingTask TaskName='VerifySdkPaths' TaskFactory='CodeTaskFactory' AssemblyFile='$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll' >
                         <ParameterGroup>     
                             <Sdk35ToolsPath />
                             <Sdk40ToolsPath />
                             <WindowsSDK80Path />
                          </ParameterGroup>
                            <Task>
                                <Using Namespace='Microsoft.Win32'/>
                                <Code>
                                <![CDATA[
                                    string pathTo35Sdk = ToolLocationHelper.GetPathToDotNetFrameworkSdkFile(""gacutil.exe"", TargetDotNetFrameworkVersion.Version35);
                                    if (!String.IsNullOrEmpty(pathTo35Sdk))
                                    {
                                        pathTo35Sdk = Path.GetDirectoryName(pathTo35Sdk) + ""\\"";
                                    }

                                    string pathTo40Sdk = ToolLocationHelper.GetPathToDotNetFrameworkSdkFile(""gacutil.exe"", TargetDotNetFrameworkVersion.VersionLatest); 

                                    if (!String.IsNullOrEmpty(pathTo40Sdk))
                                    {
                                        pathTo40Sdk = Path.GetDirectoryName(pathTo40Sdk) + ""\\"";
                                    }

                                    string pathTo81WinSDK = ToolLocationHelper.GetPathToWindowsSdk(TargetDotNetFrameworkVersion.VersionLatest, VisualStudioVersion.VersionLatest);" +
                                    s_verifyToolsetAndToolLocationHelperProjectCommonContent +
                                  @"if (!String.Equals(WindowsSDK80Path, pathTo81WinSDK, StringComparison.OrdinalIgnoreCase))
                                    {
                                        Log.LogError(""WindowsSDK80Path is incorrect! Registry: {0}  ToolLocationHelper: {1}"", WindowsSDK80Path, pathTo81WinSDK);
                                    }

                                    return !Log.HasLoggedErrors;
                                ]]>
                              </Code>
                            </Task>
                        </UsingTask>
                        <Target Name='Build'>
                            <VerifySdkPaths Sdk35ToolsPath='$(Sdk35ToolsPath)' Sdk40ToolsPath='$(Sdk40ToolsPath)' WindowsSDK80Path='$(WindowsSDK80Path)' />
                        </Target>
                    </Project>");

            ILogger logger = new MockLogger(_output);
            ProjectCollection collection = new ProjectCollection();
            Project p = ObjectModelHelpers.CreateInMemoryProject(collection, projectContents, logger);

            bool success = p.Build(logger);

            Assert.True(success); // "Build Failed.  See Std Out for details."
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:52,代码来源:ToolLocationHelper_Tests.cs


示例11: SemicolonInConfiguration_UsingTaskHost

        public void SemicolonInConfiguration_UsingTaskHost()
        {
            string originalOverrideTaskHostVariable = Environment.GetEnvironmentVariable("MSBUILDFORCEALLTASKSOUTOFPROC");

            try
            {
                Environment.SetEnvironmentVariable("MSBUILDFORCEALLTASKSOUTOFPROC", "1");
                ObjectModelHelpers.DeleteTempProjectDirectory();

                // ---------------------
                // Foo.csproj
                // ---------------------
                ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
                <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                    <Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
                    <PropertyGroup>
                        <Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
                        <Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
                        <OutputType>Library</OutputType>
                        <AssemblyName>ClassLibrary16</AssemblyName>
                    </PropertyGroup>
                    <PropertyGroup Condition=` '$(Configuration)|$(Platform)' == 'a%3bb%27c|AnyCPU' `>
                        <OutputPath>bin\a%3bb%27c\</OutputPath>
                    </PropertyGroup>
                    <ItemGroup>
                        <Reference Include=`System` />
                        <Compile Include=`Class1.cs` />
                    </ItemGroup>
                    <Import Project=`$(MSBuildBinPath)\Microsoft.CSharp.targets` />
                </Project>
            ");

                // ---------------------
                // Class1.cs
                // ---------------------
                ObjectModelHelpers.CreateFileInTempProjectDirectory("Class1.cs", @"
                namespace ClassLibrary16
                {
	                public class Class1
	                {
	                }
                }
            ");

                // Create a logger.
                MockLogger logger = new MockLogger();

                Project project = ObjectModelHelpers.LoadProjectFileInTempProjectDirectory("foo.csproj");

                // Build the default targets using the Configuration "a;b'c".
                project.SetGlobalProperty("Configuration", EscapingUtilities.Escape("a;b'c"));
                bool success = project.Build(logger);
                Assert.True(success); // "Build failed.  See Standard Out tab for details"

                ObjectModelHelpers.AssertFileExistsInTempProjectDirectory(@"obj\a;b'c\ClassLibrary16.dll");
                ObjectModelHelpers.AssertFileExistsInTempProjectDirectory(@"bin\a;b'c\ClassLibrary16.dll");

                logger.AssertLogContains(String.Format("foo -> {0}", Path.Combine(ObjectModelHelpers.TempProjectDir, @"bin\a;b'c\ClassLibrary16.dll")));
            }
            finally
            {
                Environment.SetEnvironmentVariable("MSBUILDFORCEALLTASKSOUTOFPROC", originalOverrideTaskHostVariable);
            }
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:64,代码来源:EscapingInProjects_Tests.cs


示例12: ResetLogger

 /// <summary>
 /// Un-registers the existing logger and registers a new copy.
 /// We will use this when we do multiple builds so that we can safely 
 /// assert on log messages for that particular build.
 /// </summary>
 private void ResetLogger()
 {
     engine.UnregisterAllLoggers();
     logger = new MockLogger();
     project.ParentEngine.RegisterLogger(logger);
 }
开发者ID:nikson,项目名称:msbuild,代码行数:11,代码来源:BuildItem_Tests.cs


示例13: EscapedWildcardsShouldNotBeExpanded_InTaskHost

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

            try
            {
                // Populate the project directory with three physical files on disk -- a.weirdo, b.weirdo, c.weirdo.
                EscapingInProjectsHelper.CreateThreeWeirdoFiles();
                Project project = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                    <UsingTask TaskName=`Message` AssemblyFile=`$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll` TaskFactory=`TaskHostFactory` />

                    <Target Name=`t`>
                        <ItemGroup>
                            <type Include=`%2A` Exclude=``/>
                        </ItemGroup>
                        <Message Text=`[@(type)]`/>
                    </Target>
                </Project>
                ");

                bool success = project.Build(logger);
                Assert.True(success); // "Build failed.  See Standard Out tab for details"
                logger.AssertLogContains("[*]");
            }
            finally
            {
                EscapingInProjectsHelper.CleanupWeirdoFiles();
            }
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:30,代码来源:EscapingInProjects_Tests.cs


示例14: TargetNamesAlwaysUnescaped_Override

        public void TargetNamesAlwaysUnescaped_Override()
        {
            Project project = ObjectModelHelpers.CreateInMemoryProject(@"
            <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                <Target Name=`%3B`>
                    <Message Text=`[WRONG]` />
                </Target>
                <Target Name=`;`>
                    <Message Text=`[OVERRIDE]` />
                </Target>
            </Project>
            ");
            MockLogger logger = new MockLogger();

            bool success = project.Build(logger);
            Assert.True(success); // "Build failed.  See Standard Out tab for details"
            logger.AssertLogContains("[OVERRIDE]");
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:18,代码来源:EscapingInProjects_Tests.cs


示例15: ProjectToolsVersionOverwriteIsTrue

        public void ProjectToolsVersionOverwriteIsTrue()
        {
            try
            {
                string projectContent =
                    @"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                    <Target Name=`a`>
                        <Message Text=`[a=$(MSBuildToolsVersion)]`/>
                        <MSBuild Projects=`p2.proj`/>
                        <MSBuild Projects=`p2.proj` ToolsVersion='3.5'/>
                        <MSBuild Projects=`p2.proj` ToolsVersion='2.0'/>
                    </Target>
                    </Project>
                    ";
                string projectContent2 =
                    @"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                    <Target Name=`a`>
                        <Message Text=`[b=$(MSBuildToolsVersion)]`/>
                    </Target>
                    </Project>
                    ";

                MockLogger logger = new MockLogger();
                Engine e = new Engine();
                e.RegisterLogger(logger);

                string p1Path = ObjectModelHelpers.CreateFileInTempProjectDirectory("p1.proj", projectContent);
                string p2Path = ObjectModelHelpers.CreateFileInTempProjectDirectory("p2.proj", projectContent2);

                Project p1 = new Project(e, "2.0");
                p1.Load(p1Path);
                p1.Build();

                logger.AssertLogContains("[a=2.0]");
                logger.AssertLogContains("[b=2.0]");

                Assertion.Assert("Cachescope should have an entry with 2.0", e.CacheManager.GetCacheScope(p1Path, new BuildPropertyGroup(), "2.0", CacheContentType.BuildResults) != null);
                Assertion.Assert("Cachescope should have an entry with 2.0", e.CacheManager.GetCacheScope(p2Path, new BuildPropertyGroup(), "2.0", CacheContentType.BuildResults) != null);
            }
            finally
            {
                ObjectModelHelpers.DeleteTempProjectDirectory();
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:46,代码来源:Engine_Tests.cs


示例16: GlobalPropertyWithEscapedCharacters

        public void GlobalPropertyWithEscapedCharacters()
        {
            MockLogger logger = new MockLogger();
            Project project = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                    <Target Name=`Build`>
                        <Message Text=`MyGlobalProperty = '$(MyGlobalProperty)'` />
                    </Target>
                </Project>
                ");

            project.SetGlobalProperty("MyGlobalProperty", "foo%253bbar");

            bool success = project.Build(logger);
            Assert.True(success); // "Build failed.  See Standard Out tab for details"

            logger.AssertLogContains("MyGlobalProperty = 'foo%3bbar'");
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:18,代码来源:EscapingInProjects_Tests.cs


示例17: TestTargetFrameworkPaths

        public void TestTargetFrameworkPaths()
        {
            string[] targetFrameworkVersions = { "v2.0", "v3.0", "v3.5", "v4.0", "v4.5", "" };
            foreach (var version in targetFrameworkVersions)
            {
                MockLogger logger = new MockLogger();
                string projString = ObjectModelHelpers.CleanupFileContents(
                    @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` DefaultTargets=`GetPaths` xmlns=`msbuildnamespace`>
  <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.targets` />
  <Target
      Name='GetPaths'
      DependsOnTargets='GetFrameworkPaths'>
    <Message Text='Target Framework Folder = @(_TargetedFrameworkDirectoryItem)' />
  </Target>
</Project>"
                   );
                Project project = ObjectModelHelpers.CreateInMemoryProject(
                 projString,
                 logger
                 );

                project.SetProperty("TargetFrameworkVersion", version);
                project.Build();

                string targetFrameworkVersion = project.GetPropertyValue("TargetFrameworkVersion");
                string msbuildFrameworkToolsRoot = project.GetPropertyValue("MSBuildFrameworkToolsRoot");

                if (targetFrameworkVersion.Equals("v2.0"))
                {
                    if (FrameworkLocationHelper.PathToDotNetFrameworkV20 != null)
                    {
                        logger.AssertLogContains(false/* not case sensitive */, "Target Framework Folder = " + FrameworkLocationHelper.PathToDotNetFrameworkV20);
                    }
                    else
                    {
                        // If Framework v2.0 isn't present we use the hard coded version for this validation
                        logger.AssertLogContains(false/* not case sensitive */, "Target Framework Folder = " + msbuildFrameworkToolsRoot + "v2.0.50727");
                    }
                }
                else if (targetFrameworkVersion.Equals("v3.0") || targetFrameworkVersion.Equals("v3.5"))
                {
                    logger.AssertLogContains(false/* not case sensitive */, "Target Framework Folder = " + msbuildFrameworkToolsRoot + "\\" + targetFrameworkVersion);
                }
                else if (targetFrameworkVersion.Equals("v4.0"))
                {
                    logger.AssertLogContains(false/* not case sensitive */, "Target Framework Folder = " + FrameworkLocationHelper.PathToDotNetFrameworkV40);
                }
                else if (targetFrameworkVersion.Equals("v4.5"))
                {
                    logger.AssertLogContains(false/* not case sensitive */, "Target Framework Folder = " + FrameworkLocationHelper.PathToDotNetFrameworkV45);
                }
                else if (String.IsNullOrEmpty(targetFrameworkVersion))
                {
                    logger.AssertLogContains(false/* not case sensitive */, "Target Framework Folder = " + FrameworkLocationHelper.PathToDotNetFrameworkV45);
                }
            }
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:58,代码来源:TargetsFile_Test.cs


示例18: NoLinkMetadataSynthesisWhenDefinedInProject

        public void NoLinkMetadataSynthesisWhenDefinedInProject()
        {
            string[] files = null;
            string outputPath = Path.GetTempPath() + "\\" + Guid.NewGuid().ToString("N");

            try
            {
                files = Helpers.CreateFiles("class1.cs", "File1.txt", "Content1.foo");

                MockLogger logger = new MockLogger();

                Project project = ObjectModelHelpers.CreateInMemoryProject(
                    @"
                   <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                      <PropertyGroup>
                        <OutputPath>" + outputPath + @"</OutputPath>
                        <AssemblyName>MyAssembly</AssemblyName>
                        <OutputType>Library</OutputType>
                        <Configuration>Debug</Configuration>
                        <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
                        <SynthesizeLinkMetadata>true</SynthesizeLinkMetadata>
                      </PropertyGroup>
                      <ItemGroup>
                        <Compile Include=`" + files[0] + @"` />
                        <None Include=`" + files[1] + @"` />
                        <Content Include=`" + files[2] + @"` />
                      </ItemGroup>
                      <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.Targets` />
                      <Target Name=`AfterBuild`>
                        <Message Text=`%(Compile.Identity): [%(Compile.Link)]` />
                        <Message Text=`%(None.Identity): [%(None.Link)]` />
                        <Message Text=`%(Content.Identity): [%(Content.Link)]` />
                      </Target>
                    </Project>
                ",
                 logger
                 );

                project.Build();

                logger.AssertLogContains(String.Format("{0}: []", files[0]));
                logger.AssertLogContains(String.Format("{0}: []", files[1]));
                logger.AssertLogContains(String.Format("{0}: []", files[2]));
            }
            finally
            {
                if (files != null)
                {
                    foreach (string file in files)
                    {
                        File.Delete(file);
                    }
                }

                ObjectModelHelpers.DeleteDirectory(outputPath);
            }
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:57,代码来源:TargetsFile_Test.cs


示例19: EmptyProjectsParameterResultsInNoop

        public void EmptyProjectsParameterResultsInNoop()
        {
            string projectContents = ObjectModelHelpers.CleanupFileContents(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                    <Target Name=`t` >
	                    <MSBuild Projects=` @(empty) ` />
                    </Target>
                </Project>
                ");

            MockLogger logger = new MockLogger();
            Project project = ObjectModelHelpers.CreateInMemoryProject(projectContents, logger);

            bool success = project.Build();
            Assert.IsTrue(success, "Build failed.  See Standard Out tab for details");
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:16,代码来源:MSBuild_Tests.cs


示例20: TestGetFrameworkPaths

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

            Project project = ObjectModelHelpers.CreateInMemoryProject(
                @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` DefaultTargets=`GetPaths` xmlns=`msbuildnamespace`>
  <Target Name=`GetPaths` DependsOnTargets=`GetFrameworkPaths`>
    <Message Text=`Framework 4.0 = @(_TargetFramework40DirectoryItem)` Importance=`High`/>
    <Message Text=`Framework 3.5 = @(_TargetFramework35DirectoryItem)` Importance=`High`/>
    <Message Text=`Framework 3.0 = @(_TargetFramework30DirectoryItem)` Importance=`High`/>
    <Message Text=`Framework 2.0 = @(_TargetFramework20DirectoryItem)` Importance=`High`/>
  </Target>
  <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.targets` />
</Project>",
             logger
             );

            project.Build();

            logger.AssertLogContains(false/* not case sensitive */, "Framework 4.0 = " + FrameworkLocationHelper.PathToDotNetFrameworkV40);

            // Only check .NET 3.5 and below if they're actually on the box.
            if (FrameworkLocationHelper.PathToDotNetFrameworkV35 != null)
            {
                logger.AssertLogContains(false/* not case sensitive */, "Framework 3.5 = " + FrameworkLocationHelper.PathToDotNetFrameworkV35);
                logger.AssertLogContains(false/* not case sensitive */, "Framework 3.0 = " + FrameworkLocationHelper.PathToDotNetFrameworkV30);
                logger.AssertLogContains(false/* not case sensitive */, "Framework 2.0 = " + FrameworkLocationHelper.PathToDotNetFrameworkV20);
            }
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:30,代码来源:TargetsFile_Test.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Utilities.CommandLineBuilder类代码示例发布时间:2022-05-26
下一篇:
C# UnitTests.MockEngine类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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