2 // Build.cs: Various build tests.
5 // Marek Sieradzki (marek.sieradzki@gmail.com)
7 // (C) 2005 Marek Sieradzki
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections;
31 using Microsoft.Build.BuildEngine;
32 using Microsoft.Build.Framework;
33 using Microsoft.Build.Utilities;
34 using NUnit.Framework;
36 namespace MonoTests.Microsoft.Build.BuildEngine.Various {
40 public void TestBuild1 ()
45 string documentString = @"
46 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
47 <Target Name='1' DependsOnTargets='2'>
49 <Target Name='2' DependsOnTargets='1'>
54 engine = new Engine (Consts.BinPath);
55 project = engine.CreateNewProject ();
56 project.LoadXml (documentString);
58 Assert.IsFalse (project.Build ("1"), "A1");
62 public void TestBuild2 ()
67 string documentString = @"
68 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
69 <Target Name='1' DependsOnTargets='2'>
74 engine = new Engine (Consts.BinPath);
75 project = engine.CreateNewProject ();
76 project.LoadXml (documentString);
78 Assert.IsFalse (project.Build ("1"));
82 public void TestBuild3 ()
87 string documentString = @"
88 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
91 <OnError ExecuteTargets='B' />
94 <CreateProperty Value='B'>
95 <Output TaskParameter='Value' PropertyName='B'/>
101 engine = new Engine (Consts.BinPath);
102 project = engine.CreateNewProject ();
103 project.LoadXml (documentString);
105 Assert.IsFalse (project.Build ("A"), "A1");
106 Assert.IsNotNull (project.EvaluatedProperties ["B"], "A2");
110 public void TestBuild4 ()
115 string documentString = @"
116 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
118 <Error ContinueOnError='true' Text='text' />
119 <CreateProperty Value='A'>
120 <Output TaskParameter='Value' PropertyName='A'/>
122 <OnError ExecuteTargets='B' />
125 <CreateProperty Value='B'>
126 <Output TaskParameter='Value' PropertyName='B'/>
132 engine = new Engine (Consts.BinPath);
133 project = engine.CreateNewProject ();
134 project.LoadXml (documentString);
136 Assert.IsTrue (project.Build ("A"), "A1");
137 Assert.IsNotNull (project.EvaluatedProperties ["A"], "A2");
138 Assert.IsNull (project.EvaluatedProperties ["B"], "A3");
142 public void TestBuildContinueOnError ()
147 string documentString = @"
148 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
150 <Error ContinueOnError='true' Text='text' />
151 <CreateProperty Value='A'>
152 <Output TaskParameter='Value' PropertyName='A'/>
154 <Error ContinueOnError='true' Text='text' />
159 engine = new Engine (Consts.BinPath);
160 project = engine.CreateNewProject ();
161 project.LoadXml (documentString);
163 Assert.IsTrue (project.Build ("A"), "A1");
164 Assert.IsNotNull (project.EvaluatedProperties["A"], "A2");
168 public void TestBuildContinueOnErrorFalse ()
173 string documentString = @"
174 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
176 <Error ContinueOnError='false' Text='text' />
177 <CreateProperty Value='A'>
178 <Output TaskParameter='Value' PropertyName='A'/>
184 engine = new Engine (Consts.BinPath);
185 project = engine.CreateNewProject ();
186 project.LoadXml (documentString);
188 Assert.IsFalse (project.Build ("A"), "A1");
189 Assert.IsNull (project.EvaluatedProperties["A"], "A2");