Skip to content
This repository has been archived by the owner on Oct 13, 2020. It is now read-only.

Commit

Permalink
#2: fixed installation by conditionally importing non-existing soluti…
Browse files Browse the repository at this point in the history
…on.targets

better separated properties with corresponding targets
  • Loading branch information
mkoertgen committed Aug 30, 2015
1 parent 17cd32b commit 8bc74cc
Showing 1 changed file with 48 additions and 30 deletions.
78 changes: 48 additions & 30 deletions OneClickBuild/build/OneClickBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,30 @@
<Build Condition="'$(Build)' == ''">0</Build>
</PropertyGroup>

<PropertyGroup>
<TestsProjectPattern Condition="'$(TestsProjectPattern)' == '' And $(OutputType.EndsWith('Exe'))">$(OutDir)$(AssemblyName).exe</TestsProjectPattern>
<TestsProjectPattern Condition="'$(TestsProjectPattern)' == '' And '$(OutputType)' == 'Library'">$(OutDir)$(AssemblyName).dll</TestsProjectPattern>
<TestResultsDir Condition="'$(TestResultsDir)' == ''">$(SolutionDir)testresults\</TestResultsDir>
<TestResults Condition="'$(TestResults)' == ''">$(TestResultsDir)$(ProjectName).Tests.xml</TestResults>
<NUnitPath Condition="'$(PlatformTarget)' == 'x86'">$(SolutionDir)packages\NUnit.*\tools\nunit-console-x86.exe</NUnitPath>
<NUnitPath Condition="'$(PlatformTarget)' != 'x86'">$(SolutionDir)packages\NUnit.*\tools\nunit-console.exe</NUnitPath>
<OpenCoverFilter Condition="'$(OpenCoverFilter)' == ''">+[$(AssemblyName)]* -[*]*Tests -[FluentAssertions]*</OpenCoverFilter>
<OpenCoverOutput>$(TestResultsDir)$(ProjectName).Coverage.xml</OpenCoverOutput>
<!-- exclude generated code -->
<!-- [ExcludeFromCodeCoverage] cf.: https://github.com/OpenCover/opencover/issues/195 -->
<OpenCoverExcludeAttributes Condition="'$(OpenCoverExcludeAttributes)' == ''">*DebuggerNonUserCode*;*.GeneratedCode*;*.ExcludeFromCodeCoverage*</OpenCoverExcludeAttributes>
<CoverageFailOnTargetFail Condition="'$(CoverageFailOnTargetFail)' == ''">true</CoverageFailOnTargetFail>
<CoverageReportDir>$(TestResultsDir)coverage\$(ProjectName)</CoverageReportDir>

<NuspecFile Condition="'$(NuspecFile)'==''">$(ProjectDir)Package.nuspec</NuspecFile>
<NugetSourceToDeploy Condition="'$(NugetSourceToDeploy)'==''">https://www.nuget.org</NugetSourceToDeploy>

<!--verbosity -->
<!-- NUnit verbosity: Off|Error|Warning|Info|Verbose-->
<TestVerbosity Condition="'$(TestVerbosity)' == ''">Warning</TestVerbosity>
<!--OpenCover verbosity: Off|Fatal|Error|Warn|Info|Debug|Verbose|All -->
<CoverageVerbosity Condition="'$(CoverageVerbosity)' == ''">Warn</CoverageVerbosity>
<!-- ReportGenerator Verbosity: Verbose|Info|Error -->
<CoverageReportVerbosity Condition="'$(CoverageReportVerbosity)' == ''">Error</CoverageReportVerbosity>

</PropertyGroup>
<!-- solution wide assembly info -->
<ItemGroup>
<Compile Include="$(SolutionDir)SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
</ItemGroup>

<!--Git Versioning -->
<Target Name="VersionWithGit">
<GitVersionTask.GetVersion SolutionDirectory="$(SolutionDir)" />
</Target>

<!-- NuGet Packaging -->
<PropertyGroup>
<NuspecFile Condition="'$(NuspecFile)'==''">$(ProjectDir)Package.nuspec</NuspecFile>
<NugetSourceToDeploy Condition="'$(NugetSourceToDeploy)'==''">https://www.nuget.org</NugetSourceToDeploy>
</PropertyGroup>

<Target Name="PackageWithNuGet" DependsOnTargets="Build;Version">
<PropertyGroup>
<PackageVersion>$(GitVersion_MajorMinorPatch).$(Build)</PackageVersion>
<Revision>$(GitVersion_Sha)</Revision>
</PropertyGroup>

<Warning Condition="!Exists($(NuspecFile))" Text="Skipping target because .nuspec-file is missing (expected '$(NuspecFile)')" />
<Exec Condition="Exists($(NuspecFile))"
Command="nuget pack $(NuspecFile) -Properties Version=$(PackageVersion);Revision=$(Revision);Configuration=$(Configuration)"/>
Expand All @@ -72,10 +56,23 @@
Command="nuget push $(PackageFile) -Source $(NugetSourceToDeploy)" />
</Target>



<!-- NUnit -->
<PropertyGroup>
<TestsProjectPattern Condition="'$(TestsProjectPattern)' == '' And $(OutputType.EndsWith('Exe'))">$(OutDir)$(AssemblyName).exe</TestsProjectPattern>
<TestsProjectPattern Condition="'$(TestsProjectPattern)' == '' And '$(OutputType)' == 'Library'">$(OutDir)$(AssemblyName).dll</TestsProjectPattern>
<TestResultsDir Condition="'$(TestResultsDir)' == ''">$(SolutionDir)testresults\</TestResultsDir>
<TestResults Condition="'$(TestResults)' == ''">$(TestResultsDir)$(ProjectName).Tests.xml</TestResults>
<NUnitPath Condition="'$(PlatformTarget)' == 'x86'">$(SolutionDir)packages\NUnit.*\tools\nunit-console-x86.exe</NUnitPath>
<NUnitPath Condition="'$(PlatformTarget)' != 'x86'">$(SolutionDir)packages\NUnit.*\tools\nunit-console.exe</NUnitPath>

<!--verbosity -->
<!-- NUnit verbosity: Off|Error|Warning|Info|Verbose-->
<TestVerbosity Condition="'$(TestVerbosity)' == ''">Warning</TestVerbosity>
<NunitArgs>/nologo /nodots /noshadow /framework=net-4.0 /domain=single /xml:$(TestResults) /trace=$(TestVerbosity)</NunitArgs>
</PropertyGroup>

<Target Name="TestWithNunit" DependsOnTargets="PrepareTests">
<!-- NOTE: this item group is placed inside the target scope
so it will be evaluated lazy, i.e. after NuGet Package Restore
Expand All @@ -89,6 +86,20 @@
</Target>

<!-- OpenCover -->
<PropertyGroup>
<OpenCoverFilter Condition="'$(OpenCoverFilter)' == ''">+[$(AssemblyName)]* -[*]*Tests -[FluentAssertions]*</OpenCoverFilter>
<OpenCoverOutput>$(TestResultsDir)$(ProjectName).Coverage.xml</OpenCoverOutput>
<!-- exclude generated code -->
<!-- [ExcludeFromCodeCoverage] cf.: https://github.com/OpenCover/opencover/issues/195 -->
<OpenCoverExcludeAttributes Condition="'$(OpenCoverExcludeAttributes)' == ''">*DebuggerNonUserCode*;*.GeneratedCode*;*.ExcludeFromCodeCoverage*</OpenCoverExcludeAttributes>
<CoverageFailOnTargetFail Condition="'$(CoverageFailOnTargetFail)' == ''">true</CoverageFailOnTargetFail>
<CoverageReportDir>$(TestResultsDir)coverage\$(ProjectName)</CoverageReportDir>
<!--OpenCover verbosity: Off|Fatal|Error|Warn|Info|Debug|Verbose|All -->
<CoverageVerbosity Condition="'$(CoverageVerbosity)' == ''">Warn</CoverageVerbosity>
<!-- ReportGenerator Verbosity: Verbose|Info|Error -->
<CoverageReportVerbosity Condition="'$(CoverageReportVerbosity)' == ''">Error</CoverageReportVerbosity>
</PropertyGroup>

<Target Name="OpenCoverWithNUnit" DependsOnTargets="PrepareTests">
<ItemGroup Condition="'@(NunitConsole)' == ''">
<NunitConsole Include="$(NUnitPath)"/>
Expand Down Expand Up @@ -143,5 +154,12 @@
</Target>

<!-- import custom user solution targets -->
<Import Project="$(SolutionDir)\solution.targets" />
<Target Name="EnsureOneClickBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<WarningText>OneClickBuild has not yet been initialized for this solution. Use ...</WarningText>
</PropertyGroup>
<Warning Condition="!Exists('$(SolutionDir)\solution.targets')" Text="$(WarningText)" />
</Target>

<Import Project="$(SolutionDir)\solution.targets" Condition="Exists('$(SolutionDir)\solution.targets')" />
</Project>

0 comments on commit 8bc74cc

Please sign in to comment.