Exemplo n.º 1
0
        public void WildcardsWithRecursiveDir()
        {
            ObjectModelHelpers.DeleteTempProjectDirectory();

            ObjectModelHelpers.CreateFileInTempProjectDirectory("Myapp.proj", @"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <Target Name =`Repro`>
                    <CreateItem Include=`**\*.txt`>
                      <Output TaskParameter=`Include` ItemName=`Text`/>
                    </CreateItem>
                    <Copy SourceFiles=`@(Text)` DestinationFiles=`Destination\%(RecursiveDir)%(Filename)%(Extension)`/>
                  </Target>
                </Project>
                ");

            ObjectModelHelpers.CreateFileInTempProjectDirectory("Foo.txt", "foo");
            ObjectModelHelpers.CreateFileInTempProjectDirectory(Path.Combine("Subdir", "Bar.txt"), "bar");

            MockLogger logger = new MockLogger(_testOutput);

            ObjectModelHelpers.BuildTempProjectFileExpectSuccess("Myapp.proj", logger);

            ObjectModelHelpers.AssertFileExistsInTempProjectDirectory(Path.Combine("Destination", "Foo.txt"));
            ObjectModelHelpers.AssertFileExistsInTempProjectDirectory(Path.Combine("Destination", "Subdir", "Bar.txt"));
        }
Exemplo n.º 2
0
        public void ItemsPickUpItemDefinitionMetadataFromImportedProject()
        {
            try
            {
                ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.proj", @"
                    <Project DefaultTargets=`t` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                        <ItemGroup>
                            <ItemWithDefinition Include=`foo.cs` />
                        </ItemGroup>

                        <Target Name=`t`>
                            <Message Text=`[%(ItemWithDefinition.SomeMetadata)]` />
                        </Target>

                        <Import Project=`foo2.proj` />
                    </Project>
                ");

                ObjectModelHelpers.CreateFileInTempProjectDirectory("foo2.proj", @"
                    <Project DefaultTargets=`t2` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                        <ItemDefinitionGroup>
                            <ItemWithDefinition>
                                <SomeMetadata>foo</SomeMetadata>
                            </ItemWithDefinition>
                        </ItemDefinitionGroup>

                        <Target Name=`t2` />
                    </Project>
                ");

                MockLogger logger = ObjectModelHelpers.BuildTempProjectFileExpectSuccess("foo.proj");

                logger.AssertLogContains("[foo]");
            }
            finally
            {
                ObjectModelHelpers.DeleteTempProjectDirectory();
            }
        }