I have a unit test project which contains a few XML files for data driven tests. These files are set to Build Action Content and Copy if newer or Copy always.
For the most part, this works fine. However, when I change one of the data files without changing any code, Visual Studio will not trigger a build action at all, and no XML files will be copied. Effectively, I'm running my unit tests with the old data file.
I can trigger a manual build, but I'd like to prevent such mistakes if possible. Is there some way to make Visual Studio (2008) perform the copy operation every time someone changes the content files only?
T开发者_如何学编程o clarify:
The XML file is inside the unit test project, not in the production code project. I do have a relevant [DeploymentItem]
attribute for the file set on the test being run.
I don't know if it'll help in your situation but to get around this I changed Build Action of my XML files to Embedded Resource and it seemed to do the trick.
This seems to simple of an answer, so please forgive me if you've already done it. However I used to have this issue after editing text file data sources.
To fix this I had to clean the project after every change which was annoying on a large project I was working on.
This stopped being needed once I ended up installing VS2008 on a fresh copy of Windows so it may be a configuration issue.
Before running the tests, Visual Studio invokes MSBuild on your project with the Build and Test target. If you look into Microsoft.CSharp.targets (see http://msdn.microsoft.com/en-us/library/ms164312.aspx), you can trace how files from the Content ItemGroup get copied around as part of the bulild process. AFAIK, they are declared inputs and outputs of one of the Bulild sub-targets, so MSBuild should really consider copying them if their timestamps changed.
Can you ensure that: * changes to the files are saved * you are using NTFS * when you run the build from the msbuild cmd-line, does it still not rebuild when an xml file changed?
Visual Studios MSBuild integration is pretty broken, it does obivously not do the straightforward thing of invoking The MSBuild cmd-line. (It has issues with imports being cached and all sorts of crazy, non-intuive things).
精彩评论