SpecsFor.Mvc build error

Trying to check SpecsFor.Mvc, inadvertently, I get this strange build error when trying to run a test.

Starting both in my own project and in SpecsFor latest source, I get the message "Build failed." ApplicationException from class IISTestRunnerAction. The following follows from the log file: it is not in my understanding.

Using visual studio 2012 pro and IIS Express 8.0

The following is shown in the log file:

Using the "VSMSDeploy" task from the assembly "C: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v11.0 \ Web \ Microsoft.Web.Publishing.Tasks.dll". Task "VSMSDeploy" Package / publish task Microsoft.Web.Publishing.Tasks.VSMSDeploy build downloads Microsoft.Web.Deployment, Version = 9.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 Package / publish task Microsoft.Web.Publishing.Tasks. VSMSDeploy download assembly Microsoft.Web.Delegation, Version = 7.1.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 Launching the Web deployment task from source: manifest (C: \ Users \ Chris \ Desktop \ SpecsFor-master \ SpecsFor.Mvc.Demo \ obj \ Test \ Package \ SpecsFor.Mvc.Demo.SourceManifest.xml) to the destination: package (C: \ Users \ Chris \ Desktop \ SpecsFor-master \ SpecsFor.Mvc.Demo \ OBJ \ Test \ Package \ SpecsFor.Mvc .Demo.zip). C: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v11.0 \ Web \ Microsoft.Web.Publishing.targets (4007.5): Error: The network deployment task could not be completed. (The type initializer for "Microsoft.Web.Deployment.DeploymentManager" made an exception.) The package failed to execute. Completed the task "VSMSDeploy" - FAILED.

UPDATE

Here is AssemblyStartup

[SetUpFixture] public class AssemblyStartup { private SpecsForIntegrationHost _host; [SetUp] public void SetupTestRun() { var config = new SpecsForMvcConfig(); //SpecsFor.Mvc can spin up an instance of IIS Express to host your app //while the specs are executing. config.UseIISExpress() //To do that, it needs to know the name of the project to test... .With(Project.Named("SpecsForTesting")) //And optionally, it can apply Web.config transformations if you want //it to. .ApplyWebConfigTransformForConfig("Debug"); //In order to leverage the strongly-typed helpers in SpecsFor.Mvc, //you need to tell it about your routes. Here we are just calling //the infrastructure class from our MVC app that builds the RouteTable. config.BuildRoutesUsing(r => SpecsForTesting.RouteConfig.RegisterRoutes(r)); //SpecsFor.Mvc can use either Internet Explorer or Firefox. Support //for Chrome is planned for a future release. config.UseBrowser(BrowserDriver.Chrome); //Does your application send E-mails? Well, SpecsFor.Mvc can intercept //those while your specifications are executing, enabling you to write //tests against the contents of sent messages. config.InterceptEmailMessagesOnPort(13565); //The host takes our configuration and performs all the magic. We //need to keep a reference to it so we can shut it down after all //the specifications have executed. _host = new SpecsForIntegrationHost(config); _host.Start(); } //The TearDown method will be called once all the specs have executed. //All we need to do is stop the integration host, and it will take //care of shutting down the browser, IIS Express, etc. [TearDown] public void TearDownTestRun() { _host.Shutdown(); } } 
+4
source share
4 answers

I had this error, and it turned out that I added a new project to the project. The new project did not include the same configurations, that is, the solution performed "Test", but my new project had only debug and release versions by default.

Go into Configuration Manager and make sure that all projects in your solution have the same configuration.

+3
source

If you are looking for an assembly log, it is displayed on the console by default. Here's how to capture console output:

  var stringWriter = new StringWriter(); try { // Build log is sent to console, redirect output to StringWriter Console.SetOut(stringWriter); _host.Start(); } catch (ApplicationException ex) { throw new Exception("Build failed. Output: " + stringWriter, ex); } 
+3
source

It seems that the error is actually related to MSDeploy, which SpecsFor.Mvc uses inside MSBuild to publish your site for testing. Here is the error directly from MSDeploy: The network deployment task could not be completed. (The type initializer for "Microsoft.Web.Deployment.DeploymentManager" made an exception.) . Unfortunately, there seems to be no permission.

Can you try to deploy your site manually? This command line should do the trick:

msbuild / p: DeployOnBuild = true; DeployTarget = Package; _PackageTempDir =; AutoParameterizationWebConfigConnectionStrings = false; Platform = AnyCPU

Let me know if this works, or if it explodes with a similar error.

0
source

I had exactly the same problem trying to get SpecsForMvc to work with a remote Bamboo build agent. Matt Honeycutt's answer pointed me in the right direction. I just needed to install MS Web Deploy 3.5 on a virtual machine that starts the agent to fix this error.

I also needed to install IIS Express 8 on the same virtual machine to allow SpecsForIntegrationHost to promote the site.

arni helped me better diagnose the problem, but also caused some problems later in the line when I had permission problems that tried to connect to the remote SQL Server from the application under test. These exceptions were not caught by the ApplicationException catch block, because they were of the SystemException class. They were handled by the global exception handler, bypassing the completion of the check, which was supposed to disable the integration host. This left an instance of IIS Express for each test running in the background. (Since I cannot comment on arni's answer, I added the modified code here)

 var stringWriter = new StringWriter(); try { // Build log is sent to console, redirect output to StringWriter Console.SetOut(stringWriter); _host.Start(); } catch (Exception ex) { _integrationHost.Shutdown(); throw new Exception("Build failed. Output: " + stringWriter, ex); } 
0
source

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


All Articles