CaffGeek
CaffGeek

Reputation: 22054

SpecFlow error on build server

I am getting a strange error on the build server, this does NOT happen locally.

Error during file generation. The target file 'C:...\AcceptanceTest\Features\HelloWorld.feature.cs' is read-only, but different from the transformation result. This problem can be a sign of an inconsistent source code package. Compile and check-in the current version of the file from the development environment or remove the read-only flag from the generation result. To compile a solution that contains messaging project on a build server, you can also exclude the messaging project from the build-server solution or set the msbuild project parameter to 'true' in the messaging project file.

I'm not sure what to do to fix this, I don't have a "messaging" project (or know what is being referred too). And the code is the latest

This is the full message (some folder names have been obfuscated):

13>C:\Builds\2\Services\PService\src\packages\SpecRun.Excel.1.1.0\tools\TechTalk.SpecFlow-buildfix.targets(47,5): error : Error during file generation. The target file 'C:\Builds\2\Services\PService\src\PService\Test\PService.AcceptanceTest\Features\HelloWorld.feature.cs' is read-only, but different from the transformation result. This problem can be a sign of an inconsistent source code package. Compile and check-in the current version of the file from the development environment or remove the read-only flag from the generation result. To compile a solution that contains messaging project on a build server, you can also exclude the messaging project from the build-server solution or set the msbuild project parameter to 'true' in the messaging project file. [C:\Builds\2\Services\PService\src\PService\Test\PService.AcceptanceTest\PService.AcceptanceTest.csproj] 13>C:\Builds\2\Services\PService\src\packages\SpecRun.Excel.1.1.0\tools\TechTalk.SpecFlow-buildfix.targets(47,5): error : Could not find file 'C:\Users\tfsbuild\AppData\Local\Temp\tmpPWithData.feature.xlsx.cs'. [C:\Builds\2\Services\PService\src\PService\Test\PService.AcceptanceTest\PService.AcceptanceTest.csproj] 13>C:\Builds\2\Services\PService\src\PService\Test\PService.AcceptanceTest\Features\PWithData.feature.xlsx : error : Generation error: Could not find file 'C:\Users\tfsbuild\AppData\Local\Temp\tmpPWithData.feature.xlsx.cs'. [C:\Builds\2\Services\PService\src\PService\Test\PService.AcceptanceTest\PService.AcceptanceTest.csproj]

Upvotes: 1

Views: 1173

Answers (2)

Rami A.
Rami A.

Reputation: 10582

Delete HelloWorld.feature.cs from source control.

TFS will checkout files as read-only during a build and so SpecFlow fails to re-generate the file because it already exists and SpecFlow doesn't overwrite read-only files.

I created a new request for SpecFlow to not automatically add the file to source control here: https://github.com/techtalk/SpecFlow/issues/592

Upvotes: 1

AlSki
AlSki

Reputation: 6961

I'm not sure what the messaging project refers to, that's something I haven't seen before.

However the error reads as if the problem is due to an issue with the generation of the *.feature.cs from the *.feature file, but I am confused as to why this should be happening on the build server. Normally the generation of *.feature.cs occurs in the IDE when you save the *.feature file. This gets checked in and with some version control systems (VCS) you may end up with a read-only file status.

Your error reads as the build server is trying to re-generate the *.feature.cs file and cannot overwrite it.

Some things to check;

  • What VCS are you running? Does it leave checked-in files as read-only?
  • How are you building the files on the build server? Is there a custom step involved, or is it just a simple compile?
  • Can you replicate this error on your machine by setting the *.feature.cs to read-only and running the same build script on your local machine?

Good luck.

Upvotes: 0

Related Questions