Thursday, August 07, 2008

TESTTOOLSTASK : warning VSP1024: Unable to open file 'file' for writing.

This warning occurs when doing testing with MSTest and running the test under code coverage. It is related to the warning
"warning VSP2013: Instrumenting this image requires it to run as a 32-bit process. The CLR header flags have been updated to reflect this."

and has confused me a lot. Especially since, when running the tests in a build script, the warning seems to come and go.

No fear; the solution is quite simple (thanks to this excellent forum post); here is what you need to do:
  • Find the test configuration file you're using for the test run under code coverage. It is usually called LocalTestRun.testrunconfig and resides in the solution root.
  • Open the file in a XML-editor
  • Find all the CodeCoverageItem-elements change (or add) the attribute
    instrumentInPlace from "true" to "false"
  • Save and rerun - works like a charm

But hey, I can hear some people say, what is that instrumentInPlace-attribute? Well that's the hmrpf... mmm ... eeeh - I don't know, to be honest. From the MSDN-help I only get confused:

"If you need to gather code coverage information while you are testing code in an assembly, you must first instrument that assembly. The process of instrumentation adds code that generates code coverage information into the assembly"

OK - I've got that. But what does "in place" means? Can anyone enlighten me? I haven't yet found a time when I need it...

5 comments:

Anonymous said...

fareast\dmathew:
in-place means that the instrumentation takes place on the the original dll/exe files; on the other hand, not in-place means a copy (backup) of the files are taken before any manipulation is done on them
Thanx to this post, I could fix a bug in my team build definition!

FishOfPrey said...

Thanks for the tip.

In VS2008 the setting can be changed in the GUI using Test > Edit Test Run Configurations > Local Test Run (...) > Code Coverage and unchecking Instrument assemblies in place.

Marcus said...

Ahhh - great. It can now be turned off.

Good to know.

Thank you FishOfPrey

Dipak Panchal said...

Thanks. It solved my problem.

Marcus said...

Good to hear Dipak Panchal!

It's been a while since I wrote this, so I barely remember what it was about...

Great that it still is useful.