Why doesn't $ (SolutionDir) work in Visual Studio 2012?

I have a .net 4 MVC Web Api application that I originally created in visual studio 2010. As part of this solution, I have a unit test suite.

I decorated the unit test methods with the following

[AspNetDevelopmentServerHost("$(SolutionDir)\\DataCollectionService", "/")] 

I understand that the $ (SolutionDir) parameter contains the path to the solution catalog and makes the test suite more universal, since it works in several environments. All this works fine in visual studio 2010.

However, when I open the project in visual studio 2012 and run the test package, I get the following error.

": website path '$ (SolutionDir) \ DataCollectionService does not exist ...."

If I change it to the exact path, for example

  [AspNetDevelopmentServerHost("D:\\CASLog\\Trunk\\DataCollectionService", "/")] 

It works great, although not more general.

I'm not sure if its significant, but my visual studio 2010 has a resharper, while my visual studio 2012 does not.

Any idea what is going on?

+6
source share
1 answer

Because $(SolutionDir) is actually a macro. Macros are no longer available in VS2012. One way is to use an environment variable (custom or% PathToWebRoot%). Environment variables are supported by AspNetDevelopmentServerHost. You can set the value in the ClassInitializeAttribute method using Environment.SetEnvironmentVariable.

+6
source

Source: https://habr.com/ru/post/926706/


All Articles