Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuild generation: incremental build and clean rebuild improvements #1167

29 changes: 25 additions & 4 deletions TechTalk.SpecFlow.Tools/MsBuild/TechTalk.SpecFlow.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- this setting is to workaround the bug in VS (does not detect changes during the pre-build event)
see: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=423670&wa=wsignin1.0
-->
<PropertyGroup>
<SpecFlow_UseHostCompilerIfAvailable Condition="'$(SpecFlow_UseHostCompilerIfAvailable)'==''">false</SpecFlow_UseHostCompilerIfAvailable>
<UseHostCompilerIfAvailable>$(SpecFlow_UseHostCompilerIfAvailable)</UseHostCompilerIfAvailable>
</PropertyGroup>


<PropertyGroup>

<ShowTrace Condition="'$(ShowTrace)'==''">false</ShowTrace>
<OverwriteReadOnlyFiles Condition="'$(OverwriteReadOnlyFiles)'==''">false</OverwriteReadOnlyFiles>
<ForceGeneration Condition="'$(ForceGeneration)'==''">false</ForceGeneration>
<VerboseOutput Condition="'$(VerboseOutput)'==''">false</VerboseOutput>

<SpecFlow_DeleteCodeBehindFilesOnCleanRebuild Condition="'$(SpecFlow_DeleteCodeBehindFilesOnCleanRebuild)'==''">false</SpecFlow_DeleteCodeBehindFilesOnCleanRebuild>

<ShowTrace Condition="'$(ShowTrace)'==''">false</ShowTrace>
<VerboseOutput Condition="'$(VerboseOutput)'==''">false</VerboseOutput>
<SpecFlow_DebugMSBuildTask Condition="'$(SpecFlow_DebugMSBuildTask)' == ''">false</SpecFlow_DebugMSBuildTask>

<_SpecFlowPropsImported Condition="'$(_SpecFlowPropsImported)'==''">true</_SpecFlowPropsImported>
</PropertyGroup>
</Project>

<ItemGroup>
<SpecFlowFeatureFiles Include="**\*.feature">
<CodeBehindFile>%(RelativeDir)%(Filename).feature.cs</CodeBehindFile>
</SpecFlowFeatureFiles>
<SpecFlowFeatureFiles Include="**\*.feature.xlsx">
<CodeBehindFile>%(RelativeDir)%(Filename).feature.cs</CodeBehindFile>
</SpecFlowFeatureFiles>
</ItemGroup>

</Project>
51 changes: 26 additions & 25 deletions TechTalk.SpecFlow.Tools/MsBuild/TechTalk.SpecFlow.targets
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- this setting is to workaround the bug in VS (does not detect changes during the pre-build event)
see: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=423670&wa=wsignin1.0
-->
<PropertyGroup>
<SpecFlow_UseHostCompilerIfAvailable Condition="'$(SpecFlow_UseHostCompilerIfAvailable)'==''">false</SpecFlow_UseHostCompilerIfAvailable>
<UseHostCompilerIfAvailable>$(SpecFlow_UseHostCompilerIfAvailable)</UseHostCompilerIfAvailable>
</PropertyGroup>

<Import Project="TechTalk.SpecFlow.props" Condition="'$(_SpecFlowPropsImported)'==''"/>

<PropertyGroup Condition="'$(BuildServerMode)' == ''">
Expand All @@ -23,7 +15,12 @@
AfterUpdateFeatureFilesInProject;
$(BuildDependsOn)
</BuildDependsOn>
<CleanDependsOn>
CleanFeatureFilesInProject;
$(CleanDependsOn)
</CleanDependsOn>
<RebuildDependsOn>
CleanFeatureFilesInProject;
SwitchToForceGenerate;
$(RebuildDependsOn)
</RebuildDependsOn>
Expand All @@ -32,34 +29,38 @@
<Target Name="SwitchToForceGenerate">
<PropertyGroup>
<ForceGeneration>true</ForceGeneration>
<OnlyUpdateIfChanged>true</OnlyUpdateIfChanged>
</PropertyGroup>
</Target>

<ItemGroup>
<SpecFlowFeatureFiles Include="**\*.feature"/>
<SpecFlowFeatureFiles Include="**\*.feature.xlsx" />
</ItemGroup>
<Target Name="UpdateFeatureFilesInProject"
DependsOnTargets="BeforeUpdateFeatureFilesInProject"
Inputs="@(SpecFlowFeatureFiles)"
Outputs="@(SpecFlowFeatureFiles->'%(CodeBehindFile)')">

<Target Name="UpdateFeatureFilesInProject" DependsOnTargets="BeforeUpdateFeatureFilesInProject" Inputs="@(SpecFlowFeatureFiles)" Outputs="@(SpecFlowFeatureFiles->'%(RelativeDir)\%(Filename).feature.cs')">
<GenerateAll
ShowTrace="$(ShowTrace)"
<GenerateAll ProjectPath="$(MSBuildProjectFullPath)"

BuildServerMode="$(BuildServerMode)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"

ProjectPath="$(MSBuildProjectFullPath)"
ForceGeneration="$(ForceGeneration)"
VerboseOutput="$(VerboseOutput)"
DebugTask="$(SpecFlow_DebugMSBuildTask)"
>
BuildServerMode="$(BuildServerMode)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
ForceGeneration="$(ForceGeneration)"

ShowTrace="$(ShowTrace)"
VerboseOutput="$(VerboseOutput)"
DebugTask="$(SpecFlow_DebugMSBuildTask)"
>
<Output TaskParameter="GeneratedFiles" ItemName="SpecFlowGeneratedFiles" />
</GenerateAll>

<Message Text="%(SpecFlowGeneratedFiles.Identity)" Importance="high" Condition="'$(VerboseOutput)'=='true'" />
</Target>

<Target Name="BeforeUpdateFeatureFilesInProject">
</Target>

<Target Name="AfterUpdateFeatureFilesInProject" DependsOnTargets="UpdateFeatureFilesInProject">
</Target>

<Target Name="CleanFeatureFilesInProject" Condition="'$(SpecFlow_DeleteCodeBehindFilesOnCleanRebuild)' == 'true'">
<Delete Files="%(SpecFlowFeatureFiles.CodeBehindFile)" ContinueOnError="true" />
</Target>

</Project>