本文整理汇总了C#中Microsoft.Build.UnitTests.MockLogger.AssertLogDoesntContain方法的典型用法代码示例。如果您正苦于以下问题:C# MockLogger.AssertLogDoesntContain方法的具体用法?C# MockLogger.AssertLogDoesntContain怎么用?C# MockLogger.AssertLogDoesntContain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.UnitTests.MockLogger
的用法示例。
在下文中一共展示了MockLogger.AssertLogDoesntContain方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnyCPULibraryProjectIsNot32BitPreferred
public void AnyCPULibraryProjectIsNot32BitPreferred()
{
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>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include=`" + file + @"` />
</ItemGroup>
<Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.Targets` />
</Project>
",
logger
);
project.Build();
logger.AssertLogDoesntContain(" /platform:");
}
finally
{
if (file != null)
{
File.Delete(file);
}
ObjectModelHelpers.DeleteDirectory(outputPath);
}
}
示例2: TargetStopOnFirstFailureBuildInParallel
//.........这里部分代码省略.........
target1 = "T1";
target2 = "T3";
target3 = "T2";
break;
case 3:
stopOnFirstFailure = true;
target1 = "T1";
target2 = "T2";
target3 = "T3";
break;
case 4:
stopOnFirstFailure = true;
target1 = "T1";
target2 = "T3";
target3 = "T2";
break;
case 5:
stopOnFirstFailure = false;
target1 = "T1";
target2 = "T3";
target3 = "T2";
break;
}
string parentProjectContents = @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<ItemGroup>
<Projects Include=`" + project1 + @"` />
</ItemGroup>
<ItemGroup>
<Targets Include=`" + target1 + @"` />
<Targets Include=`" + target2 + @"` />
<Targets Include=`" + target3 + @"` />
</ItemGroup>
<Target Name=`Build` Returns=`@(Outputs)`>
<MSBuild Projects=`@(Projects)` Targets=`@(Targets)` StopOnFirstFailure=`" + stopOnFirstFailure.ToString() + @"` RunEachTargetSeparately=`" + runEachTargetSeparately.ToString() + @"`>
<Output TaskParameter=`TargetOutputs` ItemName=`Outputs` />
</MSBuild>
</Target>
</Project>";
MockLogger logger = new MockLogger();
Project p = ObjectModelHelpers.CreateInMemoryProject(parentProjectContents, logger);
bool success = p.Build();
switch (i)
{
case 0:
// Test the case where the error is in the last project and RunEachTargetSeparately = true
logger.AssertLogContains("Proj2 T1 message");
logger.AssertLogContains("Proj2 T2 message");
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingTargets"));
break;
case 1:
// Test the case where the error is in the second target out of 3.
logger.AssertLogContains("Proj2 T1 message");
logger.AssertLogContains(AssemblyResources.GetString("MSBuild.SkippingRemainingTargets"));
logger.AssertLogDoesntContain("Proj2 T2 message");
// The build should fail as the first project has an error
break;
case 2:
// Test case where error is in second last target but stopOnFirstFailure is false
logger.AssertLogContains("Proj2 T1 message");
logger.AssertLogContains("Proj2 T2 message");
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingTargets"));
break;
// Test the cases where RunEachTargetSeparately is false. In these cases all of the targets should be submitted at once
case 3:
// Test the case where the error is in the last project and RunEachTargetSeparately = true
logger.AssertLogContains("Proj2 T1 message");
logger.AssertLogContains("Proj2 T2 message");
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingTargets"));
// The build should fail as the first project has an error
break;
case 4:
// Test the case where the error is in the second target out of 3.
logger.AssertLogContains("Proj2 T1 message");
logger.AssertLogDoesntContain("Proj2 T2 message");
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingTargets"));
// The build should fail as the first project has an error
break;
case 5:
// Test case where error is in second last target but stopOnFirstFailure is false
logger.AssertLogContains("Proj2 T1 message");
logger.AssertLogDoesntContain("Proj2 T2 message");
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingTargets"));
break;
}
// The build should fail as the first project has an error
Assert.False(success, "Iteration of i:" + i + "Build Succeeded. See 'Standard Out' tab for details.");
}
}
finally
{
File.Delete(project1);
}
}
示例3: AnyCPUWinMDObjProjectIsNot32BitPreferred
public void AnyCPUWinMDObjProjectIsNot32BitPreferred()
{
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>winmdobj</OutputType>
<Configuration>Debug</Configuration>
</PropertyGroup>
<!-- For dealing with the case where the Jupiter targets do not exist, in order to follow the appropriate codepaths in the standard managed
we need to be .NET 4.5 or greater -->
<PropertyGroup Condition=`!Exists('$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v1.0\Microsoft.Windows.UI.Xaml.CSharp.targets')`>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include=`" + file + @"` />
</ItemGroup>
<Import Project=`$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v1.0\Microsoft.Windows.UI.Xaml.CSharp.targets` Condition=`Exists('$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v1.0\Microsoft.Windows.UI.Xaml.CSharp.targets')` />
<!-- Fall back to CSharp targets for the sake of this test if the Jupiter targets don't exist, since what we're testing can be equally well resolved by either -->
<Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.Targets` Condition=`!Exists('$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v1.0\Microsoft.Windows.UI.Xaml.CSharp.targets')` />
</Project>
",
logger
);
project.Build();
logger.AssertLogDoesntContain(" /platform:");
}
finally
{
if (file != null)
{
File.Delete(file);
}
ObjectModelHelpers.DeleteDirectory(outputPath);
}
}
示例4: StopOnFirstFailureandBuildInParallelMultipleNode
public void StopOnFirstFailureandBuildInParallelMultipleNode()
{
string project1 = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project xmlns='msbuildnamespace' ToolsVersion='msbuilddefaulttoolsversion'>
<Target Name='msbuild'>
<Error Text='Error'/>
</Target>
</Project>
");
string project2 = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project xmlns='msbuildnamespace' ToolsVersion='msbuilddefaulttoolsversion'>
<Target Name='msbuild'>
<Message Text='SecondProject'/>
</Target>
</Project>
");
try
{
// Test the various combinations of BuildInParallel and StopOnFirstFailure when the msbuild task is told there are multiple nodes
// running in the system
for (int i = 0; i < 4; i++)
{
bool buildInParallel = false;
bool stopOnFirstFailure = false;
// first set up the project being built.
switch (i)
{
case 0:
buildInParallel = true;
stopOnFirstFailure = true;
break;
case 1:
buildInParallel = true;
stopOnFirstFailure = false;
break;
case 2:
buildInParallel = false;
stopOnFirstFailure = true;
break;
case 3:
buildInParallel = false;
stopOnFirstFailure = false;
break;
}
string parentProjectContents = @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<ItemGroup>
<Projects Include=`" + project1 + @"` />
<Projects Include=`" + project2 + @"` />
</ItemGroup>
<Target Name=`Build` Returns=`@(Outputs)`>
<MSBuild Projects=`@(Projects)` Targets=`msbuild` BuildInParallel=`" + buildInParallel.ToString() + @"` StopOnFirstFailure=`" + stopOnFirstFailure.ToString() + @"`>
<Output TaskParameter=`TargetOutputs` ItemName=`Outputs` />
</MSBuild>
</Target>
</Project>";
MockLogger logger = new MockLogger();
ProjectCollection pc = new ProjectCollection(null, new List<ILogger> { logger }, null, ToolsetDefinitionLocations.Registry | ToolsetDefinitionLocations.ConfigurationFile, 2, false);
Project p = ObjectModelHelpers.CreateInMemoryProject(pc, parentProjectContents, logger);
bool success = p.Build();
switch (i)
{
case 0:
// Verify build did build second project which has the message SecondProject
logger.AssertLogContains("SecondProject");
// Verify the correct msbuild task messages are in the log
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingProjects"));
logger.AssertLogContains(AssemblyResources.GetString("MSBuild.NoStopOnFirstFailure"));
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.NotBuildingInParallel"));
break;
case 1:
// Verify setting BuildInParallel to true and StopOnFirstFailure to
// false will cause no change in BuildInParallel
// Verify build did build second project which has the message SecondProject
logger.AssertLogContains("SecondProject");
// Verify the correct msbuild task messages are in the log
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingProjects"));
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.NoStopOnFirstFailure"));
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.NotBuildingInParallel"));
break;
case 2:
// Verify setting BuildInParallel to false and StopOnFirstFailure to
// true will cause no change in BuildInParallel
// Verify build did not build second project which has the message SecondProject
logger.AssertLogDoesntContain("SecondProject");
// Verify the correct msbuild task messages are in the log
logger.AssertLogContains(AssemblyResources.GetString("MSBuild.SkippingRemainingProjects"));
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.NoStopOnFirstFailure"));
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.NotBuildingInParallel"));
break;
case 3:
// Verify setting BuildInParallel to false and StopOnFirstFailure to
// false will cause no change in BuildInParallel
//.........这里部分代码省略.........
示例5: SkipRemainingProjects
public void SkipRemainingProjects()
{
string project1 = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project xmlns='msbuildnamespace' ToolsVersion='msbuilddefaulttoolsversion'>
<Target Name='msbuild'>
<Error Text='Error'/>
</Target>
</Project>
");
string project2 = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project xmlns='msbuildnamespace' ToolsVersion='msbuilddefaulttoolsversion'>
<Target Name='msbuild'>
<Message Text='SecondProject'/>
</Target>
</Project>
");
try
{
string parentProjectContents = @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<ItemGroup>
<Projects Include=`" + project1 + @"` />
</ItemGroup>
<Target Name=`Build` Returns=`@(Outputs)`>
<MSBuild Projects=`@(Projects)` Targets=`msbuild` BuildInParallel=`false` StopOnFirstFailure=`true`>
<Output TaskParameter=`TargetOutputs` ItemName=`Outputs` />
</MSBuild>
</Target>
</Project>";
MockLogger logger = new MockLogger();
ProjectCollection pc = new ProjectCollection(null, new List<ILogger> { logger }, null, ToolsetDefinitionLocations.Registry | ToolsetDefinitionLocations.ConfigurationFile, 2, false);
Project p = ObjectModelHelpers.CreateInMemoryProject(pc, parentProjectContents, logger);
bool success = p.Build();
logger.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingProjects"));
Assert.False(success); // "Build Succeeded. See 'Standard Out' tab for details."
parentProjectContents = @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<ItemGroup>
<Projects Include=`" + project2 + @"` />
<Projects Include=`" + project1 + @"` />
</ItemGroup>
<Target Name=`Build` Returns=`@(Outputs)`>
<MSBuild Projects=`@(Projects)` Targets=`msbuild` BuildInParallel=`false` StopOnFirstFailure=`true`>
<Output TaskParameter=`TargetOutputs` ItemName=`Outputs` />
</MSBuild>
</Target>
</Project>";
MockLogger logger2 = new MockLogger();
Project p2 = ObjectModelHelpers.CreateInMemoryProject(pc, parentProjectContents, logger2);
bool success2 = p2.Build();
logger2.AssertLogDoesntContain(AssemblyResources.GetString("MSBuild.SkippingRemainingProjects"));
Assert.False(success2); // "Build Succeeded. See 'Standard Out' tab for details."
}
finally
{
File.Delete(project1);
File.Delete(project2);
}
}
示例6: SetInputsOutputsIncremental
public void SetInputsOutputsIncremental()
{
string oldFile = null, newFile = null;
try
{
oldFile = GetTempFiles(1, new DateTime(2005, 1, 1))[0];
newFile = GetTempFiles(1, new DateTime(2006, 1, 1))[0];
MockLogger logger = new MockLogger();
Project p = ObjectModelHelpers.CreateInMemoryProject(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<Target Name=`t` Inputs=`" + newFile + "` Outputs=`" + oldFile + @"`>
<Message Text=`building target !!`/>
</Target>
</Project>
", logger);
p.Build(new string[] { "t" });
logger.AssertLogContains(new string[] { "building target !!" });
logger.ClearLog();
Target t = p.Targets["t"];
// reverse inputs and outputs
t.Inputs = (string)oldFile;
t.Outputs = (string)newFile;
p.ResetBuildStatus();
p.Build(new string[] { "t" });
logger.AssertLogDoesntContain("building target !!");
}
finally
{
DeleteTempFiles(new string[] { oldFile });
DeleteTempFiles(new string[] { newFile });
}
}
示例7: OverridePropertiesInInferredCreateProperty
public void OverridePropertiesInInferredCreateProperty()
{
string[] files = null;
try
{
files = ObjectModelHelpers.GetTempFiles(2, new DateTime(2005, 1, 1));
MockLogger logger = new MockLogger();
Project p = ObjectModelHelpers.CreateInMemoryProject(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<ItemGroup>
<i Include=`" + files[0] + "`><output>" + files[1] + @"</output></i>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include='a.resx'>
<LogicalName>foo</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include='b.resx'>
<LogicalName>bar</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include='c.resx'>
<LogicalName>barz</LogicalName>
</EmbeddedResource>
</ItemGroup>
<Target Name=`t2` DependsOnTargets=`t`>
<Message Text=`final:[$(LinkSwitches)]`/>
</Target>
<Target Name=`t` Inputs=`%(i.Identity)` Outputs=`%(i.Output)`>
<Message Text=`start:[Hello]`/>
<CreateProperty Value=""@(EmbeddedResource->'/assemblyresource:%(Identity),%(LogicalName)', ' ')""
Condition=""'%(LogicalName)' != '' "">
<Output TaskParameter=""Value"" PropertyName=""LinkSwitches""/>
</CreateProperty>
<Message Text=`end:[hello]`/>
</Target>
</Project>
", logger);
p.Build(new string[] { "t2" });
// We should only see messages from the second target, as the first is only inferred
logger.AssertLogDoesntContain("start:");
logger.AssertLogDoesntContain("end:");
logger.AssertLogContains(new string[] { "final:[/assemblyresource:c.resx,barz]" });
logger.AssertLogDoesntContain( ResourceUtilities.FormatResourceString("TaskStarted", "CreateProperty"));
logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:a.resx,foo", "/assemblyresource:b.resx,bar") });
logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:b.resx,bar", "/assemblyresource:c.resx,barz") });
}
finally
{
ObjectModelHelpers.DeleteTempFiles(files);
}
}
示例8: TaskOutputSpecifiedButNotSupported
public void TaskOutputSpecifiedButNotSupported()
{
MockLogger logger = new MockLogger();
string projectFileContents = @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<Target Name=`Build`>
<Message Text=`Building...`>
<Output TaskParameter=`NotSupported` ItemName=`MyItem` />
</Message>
<Message Text=`Got Here!` />
</Target>
</Project>";
Project project = ObjectModelHelpers.CreateInMemoryProject(projectFileContents, logger);
project.Build(null, null);
logger.AssertLogContains("MSB4131");
logger.AssertLogDoesntContain("Got Here!");
Assertion.Assert("MSBuild should have logged an error because the task does not provide the given output parameter!", logger.ErrorCount > 0);
}
示例9: FilterItemPreviouslyModified2
public void FilterItemPreviouslyModified2()
{
MockLogger logger = new MockLogger();
Project p = ObjectModelHelpers.CreateInMemoryProject(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<ItemGroup>
<x Include=`a`/>
</ItemGroup>
<Target Name=`t`>
<ItemGroup>
<x>
<m1>1</m1>
</x>
<x>
<m1 Condition=`'%(x.m1)'=='1'`>2</m1>
</x>
</ItemGroup>
<Message Text=`[%(x.m1)]`/>
</Target>
</Project>
", logger);
p.Build(new string[] { "t" });
logger.AssertLogDoesntContain("[1]");
logger.AssertLogContains("[2]");
}
示例10: PropertiesInInferredBuildCreateProperty
public void PropertiesInInferredBuildCreateProperty()
{
string[] files = null;
try
{
files = ObjectModelHelpers.GetTempFiles(2, new DateTime(2005, 1, 1));
MockLogger logger = new MockLogger();
Project p = ObjectModelHelpers.CreateInMemoryProject(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<ItemGroup>
<i Include=`" + files[0] + "`><output>" + files[1] + @"</output></i>
</ItemGroup>
<Target Name=`t2` DependsOnTargets=`t`>
<Message Text=`final:[$(p)]`/>
</Target>
<Target Name=`t` Inputs=`%(i.Identity)` Outputs=`%(i.Output)`>
<Message Text=`start:[$(p)]`/>
<CreateProperty Value='@(i)'>
<Output TaskParameter='Value' PropertyName='p'/>
</CreateProperty>
<Message Text=`end:[$(p)]`/>
</Target>
</Project>
", logger);
p.Build(new string[] { "t2" });
// We should only see messages from the second target, as the first is only inferred
logger.AssertLogDoesntContain("start:");
logger.AssertLogDoesntContain("end:");
logger.AssertLogContains(new string[] { "final:[" + files[0] + "]" });
}
finally
{
ObjectModelHelpers.DeleteTempFiles(files);
}
}