Exemple #1
0
        public void DefinitionInImportedFile()
        {
            MockLogger logger       = new MockLogger();
            string     importedFile = null;

            try
            {
                importedFile = Path.GetTempFileName();
                File.WriteAllText(importedFile, @"
                <Project ToolsVersion='3.5' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
                  <ItemDefinitionGroup>
                    <CppCompile>
                      <Defines>DEBUG</Defines>
                    </CppCompile>
                  </ItemDefinitionGroup> 
                </Project>
            ");
                Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                      <ItemGroup>
                        <CppCompile Include='a.cpp'/>                      
                      </ItemGroup>
                      <Import Project='" + importedFile + @"'/>
                      <Target Name=`t`>
                        <Message Text=`[%(CppCompile.Identity)==%(CppCompile.Defines)]`/>
                      </Target>
                    </Project>
                ", logger);
                p.Build("t");

                logger.AssertLogContains("[a.cpp==DEBUG]");
            }
            finally
            {
                ObjectModelHelpers.DeleteTempFiles(new string[] { importedFile });
            }
        }