Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added better way for creating the ProjectXML for MS Buil Task Tests.
- idea from #1724 (comment)
- made the NUnit workaround obsolete
  • Loading branch information
DerAlbertCom committed Jun 28, 2019
commit 44f51caf6e3b94cd2ccdc38475da0ef344cb3643
36 changes: 22 additions & 14 deletions src/GitVersionTask.Tests/GitVersionTaskPropertiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@ namespace GitVersionTask.Tests
[TestFixture]
public class GitVersionTaskPropertiesTests
{
const string projectXml =
@"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Configuration>Debug</Configuration>
<GitVersionTaskRoot>..\GitVersionTask\build\</GitVersionTaskRoot>
<GitVersionTaskRoot Condition=""!Exists('$(GitVersionTaskRoot)GitVersionTask.props')"">.\src\GitVersionTask\build\</GitVersionTaskRoot>
<GitVersionAssemblyFile>..\..\GitVersionTask.MsBuild\bin\$(Configuration)\$(TargetFramework)\GitVersionTask.MsBuild.dll</GitVersionAssemblyFile>
</PropertyGroup>
<Import Project='$(GitVersionTaskRoot)GitVersionTask.props'/>
<Import Project='$(GitVersionTaskRoot)GitVersionTask.targets'/>


static string CreateProjectXml()
{
var currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
return $@"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Configuration>Debug</Configuration>
<GitVersionTaskRoot>{currentDirectory}\..\..\..\..\GitVersionTask\build\</GitVersionTaskRoot>
<GitVersionAssemblyFile>{currentDirectory}\..\..\GitVersionTask.MsBuild\bin\$(Configuration)\$(TargetFramework)\GitVersionTask.MsBuild.dll</GitVersionAssemblyFile>
</PropertyGroup>
<Import Project='$(GitVersionTaskRoot)GitVersionTask.props'/>
<Import Project='$(GitVersionTaskRoot)GitVersionTask.targets'/>
</Project>";
}

(bool failed, Project project) CallMsBuild(IDictionary<string, string> globalProperties)
{
using (var stringReader = new StringReader(projectXml))
using (var stringReader = new StringReader(CreateProjectXml()))
{
StringBuilder builder;
Project project;
Expand All @@ -48,8 +53,11 @@ public class GitVersionTaskPropertiesTests
collection.UnregisterAllLoggers();
}

var consoleOutput = builder.ToString();
Console.WriteLine(consoleOutput);
if (!result)
{
var consoleOutput = builder.ToString();
TestContext.Error.Write(consoleOutput);
}

return (!result, project);
}
Expand Down