solidtoken / SpecFlow.DependencyInjection

SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.
BSD 3-Clause "New" or "Revised" License
35 stars 11 forks source link

Locally: issues building testproject with both targetframeworks #27

Closed 304NotModified closed 4 years ago

304NotModified commented 4 years ago

Hi,

I have a question,

For some reason I have build errors locally (tested on 2 machines), when both targetframeworks are enabled.

This works:

 <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1</TargetFrameworks>
    <IsPackable>false</IsPackable>
    <RootNamespace>SolidToken.SpecFlow.DependencyInjection.Tests</RootNamespace>
    <AssemblyName>SolidToken.SpecFlow.DependencyInjection.Tests</AssemblyName>
  </PropertyGroup>

This also:

 <PropertyGroup>
    <TargetFrameworks>netcoreapp3.1</TargetFrameworks>
    <IsPackable>false</IsPackable>
    <RootNamespace>SolidToken.SpecFlow.DependencyInjection.Tests</RootNamespace>
    <AssemblyName>SolidToken.SpecFlow.DependencyInjection.Tests</AssemblyName>
  </PropertyGroup>

And this gives a lot of strange build errors:

 <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
    <IsPackable>false</IsPackable>
    <RootNamespace>SolidToken.SpecFlow.DependencyInjection.Tests</RootNamespace>
    <AssemblyName>SolidToken.SpecFlow.DependencyInjection.Tests</AssemblyName>
  </PropertyGroup>
1>------ Build started: Project: SpecFlow.DependencyInjection.Tests, Configuration: Debug Any CPU ------
1>SpecFlowFeatureFiles: ContextInjectionScope.feature;DependencyInjectionPlugin.feature
1>SpecFlowGeneratedFiles: ContextInjectionScope.feature.cs
1>SpecFlowGeneratedFiles: DependencyInjectionPlugin.feature.cs
1>SpecFlowFeatureFiles: ContextInjectionScope.feature;DependencyInjectionPlugin.feature
1>SpecFlowGeneratedFiles: ContextInjectionScope.feature.cs
1>SpecFlowGeneratedFiles: DependencyInjectionPlugin.feature.cs
1>SpecFlow.DependencyInjection.Tests -> D:\github\304NotModified\SpecFlow.DependencyInjection\SpecFlow.DependencyInjection.Tests\bin\Debug\netcoreapp3.1\SolidToken.SpecFlow.DependencyInjection.Tests.dll
1>DependencyInjectionPlugin.feature(3,107,3,173): error CS0246: The type or namespace name 'SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture' could not be found (are you missing a using directive or an assembly reference?)
1>ContextInjectionScope.feature(3,99,3,165): error CS0246: The type or namespace name 'SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture' could not be found (are you missing a using directive or an assembly reference?)
1>ContextInjectionScope.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttributeAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(53,39,53,50): error CS0246: The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>DependencyInjectionPlugin.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttributeAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>DependencyInjectionPlugin.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>DependencyInjectionPlugin.feature(53,39,53,50): error CS0246: The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>ContextInjectionScope.feature(17,16,17,38): error CS0234: The type or namespace name 'SkippableFactAttributeAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(17,16,17,38): error CS0234: The type or namespace name 'SkippableFactAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(17,39,17,50): error CS0246: The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>Done building project "SpecFlow.DependencyInjection.Tests.csproj".
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Any idea what's wrong? It's working with you guys?

I'm using Visual Studio 2019 16.4.5 (also the same issue was on 16.4.4, just updated and retested it)

mbhoek commented 4 years ago

It's a problem with SpecFlow (XUnitAssemblyFixture), which I solved in #18 for CI/CD but it still occurs in VS2019 occasionally (only if you try to build the project, not if you're using the NuGet package). Background info at https://github.com/SpecFlowOSS/SpecFlow/issues/1825; their suggestion of disabling Full Solution Analysis in VS 2019 does work, but it's not the solution I'm looking for..

BTW, you can run the tests from the command line using dotnet:

dotnet test --configuration Release --framework netcoreapp2.1 SpecFlow.DependencyInjection.Tests
dotnet test --configuration Release --framework netcoreapp3.1 SpecFlow.DependencyInjection.Tests

Again, this is a workaround.

304NotModified commented 4 years ago

Thanks! I think also it's https://github.com/SpecFlowOSS/SpecFlow/issues/1825 :)