Skip to content

Commit

Permalink
MSBuild generation: incremental build and clean rebuild improvements (#…
Browse files Browse the repository at this point in the history
…1167)

* Move UseHostCompilerIfAvailable Properties to props file

* Add additional VerboseOutput for generated files

* Try to fix incremental build issue inside visual studio 2017 if feature file changed outside of visual studio

- typically you'll see the message 'target skipped because of no input files changed'
- this fix should also work more reliable if using msbuild from commandline
- this fix should also improve compatibility with new skd based msbuild projects

* add experimental support for deleting codebehind files on clean or rebuild

to use codebehind file deletion you'll have to set the msbuild property 'SpecFlow_DeleteCodeBehindFilesOnCleanRebuild' to 'true' inside your csproj or using on of the directory or solution extension points in MSBuild https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build

* removed unused msbuild property

* update changelog.txt

* Fix broken DependsOn target order
  • Loading branch information
DanielTheCoder authored and SabotageAndi committed Jun 8, 2018
1 parent 5edc013 commit 4afee2c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 67 deletions.
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>

0 comments on commit 4afee2c

Please sign in to comment.