简体   繁体   中英

“aspnet_compiler.exe” exited with code 1, tried all the other posts with the same title

Project:

  • ASP.NET 4.5.2
  • MVC 5
  • Visual Studio 2015 (latest)

When building the project, today it mysteriously began erroring out with the error in the title. Now, it is not the build which is failing, but the publish:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

Now, I have gone into the temp build folder, at

[path to project]\obj\Release\AspnetCompileMerge\Source

And it seems to have all the files needed to push to the sandbox, but when I do so attempting to reach the site errors out with a massive message (50+ lines). Will append once I have them formatted.

Suggestions?


NOTE: Other projects still compile just fine. This is limited to this project, specifically.


NOTE 2: I have seen several requests to use aspnet_compiler.exe with the -errorstack flag in the commandline, but I have yet to figure out what the -v and -p flags mean, so I am currently unable to provide the output. I have never used the commandline for development before, so details would be appreciated.


UPDATE 1: I actually figured out the command, and this is what I got:

D:\[path to project]>aspnet_compiler.exe -errorstack -v /[project] -p D:\[path to project]\
Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.33440
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.

D:\[path to project]\web.config(43): error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

[ConfigurationErrorsException]: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. (D:\[path to project]\web.config line 43)
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Web.Configuration.RuntimeConfig.GetSectionObject(String sectionName)
   at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)
   at System.Web.Configuration.RuntimeConfig.get_Compilation()
   at MTConfigUtil.GetCompilationConfig(String vpath)
   at System.Web.Compilation.BuildManager.IsBatchEnabledForDirectory(VirtualPath virtualDir)
   at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallback callback, IEnumerable`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
   at System.Web.Compilation.Precompiler.Main(String[] args)

In particular, note:

This error can be caused by a virtual directory not being configured as an application in IIS. (D:\[path to project]\web.config line 43)

Problem is, the only thing in my Web.Config at that line is

<authentication mode="None" />

You see, because the IIS built into VS 2015 crashes every time I stop debugging, I set up IIS on Windows itself and just pointed it toward my project directory. But it was working just fine up until now. Could this be the issue?


EDIT 2: Commenting out line 43 in my Web.Config now throws this:

This error can be caused by a virtual directory not being configured as an application in IIS. (D:\[path to project]\web.config line 46)

Clearly there is something very, very strange. Considering I have published at least twice since I last changed my Web.Config.

Ended up doing a backup of the project, nuking it from orbit, repaving with a new blank project, adding back in all the required NuGet packages and then copying over from the backup all the files I had directly edited. Including all the Migrations files also helped, as it meant I could pick up with the DB right where I left off. The only thing I had to walk through with a fine-toothed comb was the Web.Config -- I wanted to make sure this was set up perfectly, so I hand-edited it like a surgeon doing brain surgery.

FYI, I coped everything over through the file system while the project was unloaded, and then “included into the project” anything I had previously created from scratch.

Not the ideal situation, but hey. This project is still under construction, so I lost just about an hour or two at the most doing the rebuild. The tough part was dumping my Team Services repository, as it wouldn't accept the new project. I did this after I confirmed the new setup was working 100%, as I wasn't too concerned about not being able to roll back beyond a certain date.

After refactoring a solution I had a file containing a commented out class, so it only had the using clauses and namespace set. It was using a namespace that was no longer in use by any files but may have been cached somehow so didn't immediately error.

Building didn't pick it up and it caused the aspnet_compiler exited with code 1 error plus a few other unrelated errors that weren't errors. Removing the empty class file fixed it. Also remove any old namespaces from Views/web.config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM