SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.24k stars 754 forks source link

Access to the path 'filePath'.feature.cs is denied - error message after update to version 3.1.89 #1911

Closed ZaPaw closed 3 years ago

ZaPaw commented 4 years ago

SpecFlow Version:

Used Test Runner

Version number: NUnit 3.12.0 NUnit3TestAdapter 3.16.1

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<SpecFlow> Section in app.config or content of specflow.json

Repro Project

Issue Description

After update: SpecFlow, SpecFlow.Tools.MsBuild.Generation and SpecFlow.NUnit from version 3.1.86 to version 3.1.89, I get error when I try to Build project. On 3.1.86 version everything was ok.

Error message: "Severity Code Description Project File Line Suppression State Error [SpecFlow] System.UnauthorizedAccessException: Access to the path _'filePath.feature.cs'_ is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) at System.IO.File.WriteAllText(String path, String contents) at SpecFlow.Tools.MsBuild.Generation.CodeBehindWriter.WriteCodeBehindFile(String outputPath, String featureFile, TestFileGeneratorResult testFileGeneratorResult) at SpecFlow.Tools.MsBuild.Generation.FeatureFileCodeBehindGenerator.d__6.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at SpecFlow.Tools.MsBuild.Generation.ProjectCodeBehindGenerator.GenerateCodeBehindFilesForProject() at SpecFlow.Tools.MsBuild.Generation.GenerateFeatureFileCodeBehindTaskExecutor.Execute() TheNgWeb.UiTest D:\Product\packages\specflow.tools.msbuild.generation\3.1.89\build\SpecFlow.Tools.MsBuild.Generation.targets 93
"

Steps to Reproduce

Update: SpecFlow, SpecFlow.Tools.MsBuild.Generation and SpecFlow.NUnit from version 3.1.86 to version 3.1.89 in NuGet Package Manager in Visual Studio 2017.

SabotageAndi commented 4 years ago

Is this on your local machine or on a build server?

ZaPaw commented 4 years ago

On my local machine.

SabotageAndi commented 4 years ago

I assume this is in Visual Studio. Could you close it and compile your project on the command line?

I looked at the changes between 3.1.86 and 3.1.89 and there isn't anything about file access.

SabotageAndi commented 4 years ago

Btw, which .NET Core SDK are you using? We have some problems with the new 3.1.200 Sdk ( #1912 )

ZaPaw commented 4 years ago

Thank you for the quick response to this ticket. .Net Core SDK version for my project is 2.1.509. For compile project from command line -> I haven't got set up my enviroment for this. I will try and answer tomorrow. Btw, This error appear on 2 difference machine but in the same project.

ZaPaw commented 4 years ago

I compile project in command line using MSBuild and I get error:

Build FAILED.

".csproj" (default target) (1) ->

.csproj : error MSB4247: Could not load SDK Resolver. A manifest file exists, but the path to the SDK Resolver DLL file could not be found. Manifest file path 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\SdkResolvers\Microsoft.Build.NuGetSdkResolver\Microsoft.Build.NuGetSdkResolver.xml'. SDK resolver path: C:\Program Files (x86)\Microsoft Visual Studio\2017 \BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll 0 Warning(s) 1 Error(s) After change version to 3.1.86, build succeeded.
SabotageAndi commented 4 years ago

and with a dotnet build?

ZaPaw commented 4 years ago

Sorry for the long response time.

Can you explain to me what you mean by writing "and with a dotnet build" because I didn't get it?

For more information, this error is not related to new version. I get this error when I change some data in feature file too. For while change structure to be more flat ( shorter path) was solution but now I am still getting this error.

SabotageAndi commented 4 years ago

You wrote that you used MSBuild to compile from commandline, so a msbuild call. I suggested to change this to a dotnet build call.

ZaPaw commented 4 years ago

After change to dotnet build I get Build FAILED message. Below I add screenshot. Capture2

SabotageAndi commented 3 years ago

@ZaPaw do you get this error?

ZaPaw commented 3 years ago

@SabotageAndi for a long time I havn't got this error. But code had few refactors.

SabotageAndi commented 3 years ago

Ok, then I am closing this issue.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.