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 Extended support for net.sdk project type system (targeting desktop framework, not core) #1223

Merged
merged 13 commits into from Aug 7, 2018

Conversation

DanielTheCoder
Copy link
Contributor

@DanielTheCoder DanielTheCoder commented Aug 2, 2018

This pull request extends support for net.sdk project system when MSBuild Generation is used

  • enables usage of net.sdk project type system when targeting desktop framework => not .net core support
  • globbing support for nesting codebehind files under feature files
  • fixed handling of added and removed codebehind files after regeneration
  • added warning if codebehind files without corresponding feature file is present (only for net.sdk project system enabled by default)

As this integration is experimental, you have to enable it via the following MSBuild property

  <PropertyGroup>
    <!-- enable experimental support for net.sdk projects via feature flag -->
    <SpecFlow_EnableDefaultCompileItems>true</SpecFlow_EnableDefaultCompileItems>
    <!-- enable experimental support to warn if code behind files are exisiting without corresponding feature file -->
    <SpecFlow_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingFeatureFile>true</SpecFlow_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingFeatureFile>
  </PropertyGroup>

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added an entry to the changelog

@SabotageAndi
Copy link
Contributor

When executing the Specs tests there is a problem:

TechTalk.SpecFlow.Specs.Features.SpecifyingTheCultureToBeUsedForArgumentConversionsFeature.TheBindingCultureCanBeSpecifiedToBeDifferentThanTheScenarioCulture
Microsoft.Build.Exceptions.InvalidProjectFileException : The attribute "Update" in element is unrecognized. C:\projects\specflow-kx1o3\Tests\TechTalk.SpecFlow.Specs\bin\Release\SpecFlow\Tools\TechTalk.SpecFlow.targets
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Internal.ProjectXmlUtilities.ThrowProjectInvalidAttribute(XmlAttributeWithLocation attribute)
at Microsoft.Build.Internal.ProjectXmlUtilities.VerifyThrowProjectAttributes(XmlElementWithLocation element, String[] validAttributes)
at Microsoft.Build.Construction.ProjectParser.ParseProjectItemElement(XmlElementWithLocation element, ProjectItemGroupElement parent)
at Microsoft.Build.Construction.ProjectParser.ParseProjectItemGroupElement(XmlElementWithLocation element, ProjectElementContainer parent)
at Microsoft.Build.Construction.ProjectParser.ParseProjectRootElementChildren(XmlElementWithLocation element)
at Microsoft.Build.Construction.ProjectParser.Parse()
at Microsoft.Build.Construction.ProjectParser.Parse(XmlDocumentWithLocation document, ProjectRootElement projectRootElement)
at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext)
at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext) at Microsoft.Build.Construction.ProjectRootElement.<>c__DisplayClass169_0.<OpenProjectOrSolution>b__0(String path, ProjectRootElementCache cache) at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded) at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, Boolean isExplicitlyLoaded)
at Microsoft.Build.Evaluation.Evaluator4.<>c__DisplayClass68_1.<ExpandAndLoadImports>b__0(String p, ProjectRootElementCache c) at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded) at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, String importExpressionEscaped, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator4.Evaluate() at Microsoft.Build.Evaluation.Evaluator4.Evaluate(IEvaluatorData4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary1 environmentProperties, ILoggingService loggingService, IItemFactory2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, ProjectInstance projectInstanceIfAnyForDebuggerOnly) at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation) at Microsoft.Build.Evaluation.Project.Initialize(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
at TechTalk.SpecFlow.Specs.Drivers.MsBuild.ProjectGenerator.CreateProject(InputProjectDriver inputProjectDriver, String outputFileName) in C:\projects\specflow-kx1o3\Tests\TechTalk.SpecFlow.Specs\Drivers\MsBuild\ProjectGenerator.cs:line 214
at TechTalk.SpecFlow.Specs.Drivers.MsBuild.ProjectGenerator.GenerateProject(InputProjectDriver inputProjectDriver) in C:\projects\specflow-kx1o3\Tests\TechTalk.SpecFlow.Specs\Drivers\MsBuild\ProjectGenerator.cs:line 44
at TechTalk.SpecFlow.Specs.StepDefinitions.ProjectSteps.CompileInternal() in C:\projects\specflow-kx1o3\Tests\TechTalk.SpecFlow.Specs\StepDefinitions\ProjectSteps.cs:line 74
at TechTalk.SpecFlow.Specs.StepDefinitions.ProjectSteps.EnsureCompiled() in C:\projects\specflow-kx1o3\Tests\TechTalk.SpecFlow.Specs\StepDefinitions\ProjectSteps.cs:line 63
at TechTalk.SpecFlow.Specs.StepDefinitions.ExecutionSteps.WhenIExecuteTheTests() in C:\projects\specflow-kx1o3\Tests\TechTalk.SpecFlow.Specs\StepDefinitions\ExecutionSteps.cs:line 35
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) in C:\projects\specflow-kx1o3\TechTalk.SpecFlow\Bindings\BindingInvoker.cs:line 71
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments) in C:\projects\specflow-kx1o3\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 411
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance) in C:\projects\specflow-kx1o3\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 316
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep() in C:\projects\specflow-kx1o3\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 137

I would say, the version of MSBuild we use in the Specs project is to old.

@DanielTheCoder
Copy link
Contributor Author

I've updated the test projects to use the already used nuget package for msbuild instead of .net 4.0 references.

@DanielTheCoder
Copy link
Contributor Author

Seems like we are running into the following MSBuild Issue.
Before merging, have to change using the old syntax for now to fix this issue.
dotnet/msbuild#1618

…e only if net.sdk style projects will be used.

currently, many projects are moving codebehind files into a different location using AfterUpdateFeatureFilesInProject Target
@DanielTheCoder
Copy link
Contributor Author

@SabotageAndi hopefully I'm ready with the PR for review 😎

Copy link
Contributor

@gasparnagy gasparnagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. we should also document the experimental settings at https://specflow.org/documentation/Generate-Tests-from-MsBuild/

@SabotageAndi SabotageAndi merged commit 460b037 into master Aug 7, 2018
@SabotageAndi SabotageAndi deleted the MSBuild_NetSdkProjectTypeSupport branch July 2, 2019 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants