Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -78,6 +78,61 @@ Log.LogWarning(""Hello, world!"");
Assert.IsTrue (project.Build (new ConsoleLogger (LoggerVerbosity.Diagnostic)), "Build");
}
[Test]
public void HelloWithParameter ()
{
string project_xml = @"<Project ToolsVersion='4.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<UsingTask
TaskName='DoNothing'
TaskFactory='CodeTaskFactory'
AssemblyFile='$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll' >
<ParameterGroup>
<Message ParameterType='System.String' Required='true' />
</ParameterGroup>
<Task>
<Code Type='Fragment' Language='cs'>
<![CDATA[
Log.LogWarning(""Message: "" + Message);
]]> </Code>
</Task>
</UsingTask>
<Target Name='default'>
<DoNothing Message='Hello, world!'/>
</Target>
</Project>";
var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml)));
root.FullPath = "CodeTaskFactoryTest.HelloWithParameter.proj";
var project = new Project (root);
Assert.IsTrue (project.Build (new ConsoleLogger (LoggerVerbosity.Diagnostic)), "Build");
}
[Test]
public void Reference ()
{
string project_xml = @"<Project ToolsVersion='4.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<UsingTask
TaskName='DoNothing'
TaskFactory='CodeTaskFactory'
AssemblyFile='$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll' >
<ParameterGroup />
<Task>
<Reference Include='System.Drawing' />
<Code Type='Fragment' Language='cs'>
<![CDATA[
Log.LogWarning(""Color: "" + System.Drawing.Color.CornflowerBlue);
]]> </Code>
</Task>
</UsingTask>
<Target Name='default'>
<DoNothing />
</Target>
</Project>";
var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml)));
root.FullPath = "CodeTaskFactoryTest.Reference.proj";
var project = new Project (root);
Assert.IsTrue (project.Build (new ConsoleLogger (LoggerVerbosity.Diagnostic)), "Build");
}
[Test]
public void MultipleCodeElements ()
{

View File

@@ -30,6 +30,7 @@ using System.IO;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
using System.Text;
using System.Threading;
using Microsoft.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
@@ -303,7 +304,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
Assert.AreEqual (FileAttributes.Normal, File.GetAttributes (target_file), "A3");
}
#if NET_3_5
[Test]
public void TestCopy_OverwriteReadOnlyTrue ()
{
@@ -319,7 +319,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
Assert.AreEqual (FileAttributes.ReadOnly, File.GetAttributes (target_file), "A1");
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
<PropertyGroup><DestFile>" + target_file + @"</DestFile></PropertyGroup>
<ItemGroup>
<SFiles Include='" + file_path + @"'><Md>1</Md></SFiles>
@@ -396,7 +396,61 @@ namespace MonoTests.Microsoft.Build.Tasks {
File.SetAttributes (target_file, FileAttributes.Normal);
}
#endif
[Test]
public void TestCopy_Retries ()
{
Engine engine;
Project project;
string file_path = Path.Combine (source_path, "copyretries.txt");
string target_file = Path.Combine (target_path, "copyretries.txt");
using (File.CreateText (file_path)) { }
using (File.CreateText (target_file)) { }
File.SetAttributes (target_file, FileAttributes.ReadOnly);
Assert.AreEqual (FileAttributes.ReadOnly, File.GetAttributes (target_file), "A1");
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup><DestFile>" + target_file + @"</DestFile></PropertyGroup>
<ItemGroup>
<SFiles Include='" + file_path + @"'><Md>1</Md></SFiles>
<DFiles Include='$(DestFile)'><Mde>2</Mde></DFiles>
</ItemGroup>
<Target Name='1'>
<Copy SourceFiles='@(SFiles)' DestinationFiles='@(DFiles)' Retries='3' RetryDelayMilliseconds='2000'>
<Output TaskParameter='CopiedFiles' ItemName='I0'/>
<Output TaskParameter='DestinationFiles' ItemName='I1'/>
</Copy>
<Message Text=""I0 : @(I0), I1: @(I1)""/>
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
TestMessageLogger testLogger = new TestMessageLogger ();
engine.RegisterLogger (testLogger);
project.LoadXml (documentString);
// remove the read-only flag from the file after a few secs,
// so copying works after retries
new Thread ( () => {
Thread.Sleep (3000);
File.SetAttributes (target_file, FileAttributes.Normal);
}).Start ();
if (!project.Build ("1")) {
var sb = new StringBuilder ();
testLogger.DumpMessages (sb);
Assert.Fail ("Build failed " + sb.ToString ());
}
testLogger.CheckLoggedAny ("Copying failed. Retries left: 3.", MessageImportance.Normal, "A2");
}
void CheckCopyBuildItems (Project project, string [] source_files, string destination_folder, string prefix)
{

View File

@@ -252,7 +252,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
}
#if NET_3_5 || NET_4_0
[Test]
public void TestItemsWithWildcards () {
Engine engine = new Engine (Consts.BinPath);
@@ -369,7 +368,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
Directory.Delete (basedir, true);
}
}
#endif
void CreateDirectoriesAndFiles (string basedir, string[] dirs, string[] files) {
foreach (string dir in dirs)

View File

@@ -25,7 +25,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#if NET_3_5
using System;
using System.Collections;
@@ -125,4 +124,3 @@ namespace MonoTests.Microsoft.Build.Tasks {
}
}
}
#endif