I am trying to use SpecsFor MVC for automated acceptance testing and I have noticed that it is not building / publishing project correctly on Visual Studio 2012 and hence IIS Express is not running, ending in a 'Page cannot be displayed' message throughout the automated acceptance test.
To take you through all my tests to get this working, initially, when trying to run the automated tests, I was getting a 'Build Failed' message when running
_host = new SpecsForIntegrationHost(config);
_host.Start();
. After loading the SpecsFor MVC source code, I have noticed that the error was because the MSBuild.exe process was failing and the output message was being written to Console.Output. After checking the output, I have noticed that the error was that the Microsoft.WebApplication.targets was not found. After some research, I found the below:
- External VS2013 build error "error MSB4019: The imported project <path> was not found"
- The one with most votes spoke about removing the
<PropertyGroup>node from the.csprojwhich after removing it, theMSBuild.exewas not exiting with an error code as it only had warnings which still resulted in the project not being built & published correctly. SpecsFor MVC in this case treated this scenario as successful and proceeded with launching IIS Express but since the project was not built successfully, the acceptance tests resulted in anotherPage Cannot Be Displayedmessage as IIS Express was not running correctly.
- The one with most votes spoke about removing the
- After some further research, I found v11.0\WebApplications\Microsoft.WebApplication.targets was not found when file actually references v10 which outlined that VS 2012 has a new different MSBuild.exe file located in
C:\Program Files (x86)\MSBuild\12.0\Bin.- Now the issue is that within the SpecsFor MVC
IISTestRunnerAction.PublishSite()method, the path of theMSBuild.exeis being loaded throughSystem.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()which in my case is outputtingC:\Windows\Microsoft.NET\Framework64\v4.0.30319\. Changing this manually toC:\Program Files (x86)\MSBuild\12.0\Binsolved the issue and project was built & published successfully.
- Now the issue is that within the SpecsFor MVC
My final question is: Is there a way where one can change the value of System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() so that I wouldn't need to update the source of the SpecsFor MVC project?
Thanks in advance for any help!