I have a .net 4 MVC Web Api application that I originally built in visual studio 2010. As part of this solution I have a suite of unit test.
I have decorated the unit test methods with the following
[AspNetDevelopmentServerHost("$(SolutionDir)\\DataCollectionService", "/")]
My understanding is that the "$(SolutionDir)" parameter holds the path to the solution directory, and makes the test suite more generic as it works in multiple environments. This all works great in visual studio 2010.
However when I open the project in visual studio 2012 and try run the test suite i get the following error
"message: the Web site path '$(SolutionDir)\DataCollectionService' does not exist...."
If I change it to the exact path like
[AspNetDevelopmentServerHost("D:\\CASLog\\Trunk\\DataCollectionService", "/")]
It works fine, although its not longer generic.
I'm not sure if its significant but my visual studio 2010 has resharper, while my visual studio 2012 does not.
Any idea whats going on?
Because $(SolutionDir)
is in fact a macro. Macros are no longer available in VS2012.
One workaround is to use an environment variable (custom or %PathToWebRoot%). Environment variables are supported by AspNetDevelopmentServerHost. You can set the value in a ClassInitializeAttribute method with Environment.SetEnvironmentVariable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With