可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
My project builds all fail but I'm not shown any errors. I tried cleaning and rebuilding, that didn't work.
I changed the MSBuild output verbosity to 'Diagnostic' hoping it would help me identify the problem and now I'm stuck. Here's what the output looks like:
1>Project 'ProjectMM.Data.Models' is not up to date. Input file 'C:\Projects\ProjectMM\ProjectMM.Data.Models\ProjectMM.Data.Models.csproj' is modified after output file 'C:\Projects\ProjectMM\ProjectMM.Data.Models\bin\Debug\ProjectMM.Data.Models.pdb'.
All packages are already installed and there is nothing to restore.
1>------ Build started: Project: ProjectMM.Data.Models, Configuration: Debug Any CPU ------
2>Project 'ProjectMM.Data' is not up to date. Input file 'C:\Projects\ProjectMM\ProjectMM.Data\ProjectMM.Data.csproj' is modified after output file 'C:\Projects\ProjectMM\ProjectMM.Data\bin\Debug\ProjectMM.Data.pdb'.
2>------ Build started: Project: ProjectMM.Data, Configuration: Debug Any CPU ------
3>Project 'ProjectMM' is not up to date. Input file 'c:\projects\projectmm\projectmm\app_start\bundleconfig.cs' is modified after output file 'C:\Projects\ProjectMM\ProjectMM\bin\ProjectMM.pdb'.
3>------ Build started: Project: ProjectMM, Configuration: Debug Any CPU ------
========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped ==========
回答1:
I have had the same problem and closing and re-opening Visual Studio clears it up.
I had also tried Cleaning the solution and the Clean Failed as well.
There may be other scenarios where this does not do the trick, but in my case restarting has resolved this for me.
回答2:
It's possible that you're not seeing all the build errors.
By changing the drop down list after the "Messages" icon from "Build + Intellisense" to "Build Only", you will be able to see errors thrown during the build that are not detected by Intellisense. See the screenshot below:
回答3:
I've been seeing regular instances of VS2015 reporting "build failed" but not showing any errors in the error window. Coming from an ancient command line background, I finally went looking at the output window. The output window showed the compiler reporting errors but those errors were not being captured to the error window. I never saw this problem under VS2013.
The usual closing of VS and reopening of it hasn't cleared this condition. (In VS2013 this was a common way to kick XAML intellisense in the rear and make it stop fixating on an "error" that had been fixed.)
So far this has always been related to compilation errors in a XAML page CS file. I can't remember seeing it in a non-page CS file.
Until one figures out to go check the output window, things like intellisense reporting in the error window invalid references to objects in the XAML, but no compiler errors being shown in the error window can get VERY confusion since it "appears" like the errors are the intellisense reporting XAML errors. But they actually aren't. The XAML errors are just symptoms of CS files failing to compile but not having their errors reporting in the error window.
回答4:
Deleting the hidden .vs
folder for worked for me for VS2015.
(Note that this is where the SUO files live now)
回答5:
This might happen when you reference a different .net framework version project (v4.5.2 vs v4.5 in my case). Correcting this will fix your problem.
回答6:
I had this problem with VS2015 Update 3 RC and Xamarin (.Forms shared project).
Compiler don't stop, errors were only showed in the output window.
This only for Xamarin projects (with VB.NET projects all has worked as expected)...
To try find the reason for the problem, I have changed the Build Output in VS:
- menu "Tools - Options"
- from the left panel: "Projects And Solutions: Build And Run":
- change "MSBuild Output Verbosity" from "Minimal" to "Diagnostic"
After doing that, the compiler has stopped and the error was showed..
After that, I have set the option back from "Diagnostic" to "Minimal" (like it was before) and... it has worked also with "Minimal" (to be sure, I also have restarted VS)...
So.. it seems (at least im my case) that only to change (touch) the setting (MSBuild Output Verbosity") has solved the problem and that this is a bug in VS and/or the Xamarin integration Software...
回答7:
What happened by me was, changing the timezone on the computer to +5:30 and then changing it back -5:00 is what confused VS. When I restarted VS, it worked fine again.
回答8:
Check all your project Framework versions, and make sure they're all the same, or at least that project A doesn't reference project B when project B's .NET Framework version is higher.
回答9:
I don't know whether I am the only one who is facing this problem. in my case when I opened Visual Studio the timezone was in GMT+1:00 and the build was successful and then I changed the timezone to GMT+5:30 and then without restarting the Visual Studio I tried to run the application but the build failed without any error or warning, then I changed back the timezone to GMT+1:00 and the build succeeded without any error.
回答10:
I had this problem and it turned out that I had a using
pointing to an empty namespace. Removing that using
clause fixed the problem
回答11:
Check the warnings..
I had the new class library with target .Net Framework 4.5 while the referencing project was 4.0 which caused reference issue.
After modifying the class library with target .Net Framework 4.0 it worked correctly.
回答12:
For me this issue was related to a custom CodeAnalysis ruleset setting "IncludeAll".
It appears the Compiler observes this setting:
<IncludeAll Action="Error" />
But IntelliSense took the default ACTION on the Rule Id which was "Warning". This would explain the behavior seen by @RobertHarvey where you filter the output by Build Only and it shows as an ERROR, but if you filter by Intellisene Only it shows as WARNING. Filtering output by the default Build + Intellisense seems non-deterministic!
My fix was to explicitly call out the rule that i wanted to be a warning as a warning.
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
<Rule Id="CS0618" Action="Warning" />
</Rules>
This is potentially a problem with Intellisense not observing the IncludeAll option. See https://github.com/dotnet/roslyn/issues/7400
回答13:
What I did (after all the above, and it still wasn't working) was go through all the bin folders and clear them all out (ie the referenced projects too).
This worked for me, hope it does for you too.
回答14:
This can also happen when migrating a project to Visual Studio 2015 with an older Framework. Check your Warnings in your Error List. You may see something like project is currently .NET version 2.0 and requires .NET 3.5 or higher. If you find a similar warning go to your project's properties and target the required .NET Framework.
回答15:
When open a solution, generate it, I can see some build errors or warnings reported in the "Output tab", while the "Error tab" does not report any problem.
You can see that the "Error tab" config is OK ("Build only" and "Entire solution" selected).
Note that, after a deep investigation, I identified that this only occurs only if the "Error tab" was not shown yet when you start the build!
If you activated the "Error tab" before doing the build (or if it was the current tab when you launched Visual), then newly found errors/warnings will show up correctly:
It's as if the "Error tab" is initialized only when it gets visible (which may be true as it takes more time to show up first time you click it...), and, if it was not, it does not gather build results...
So far, having no better answer to this problem than "activate the Error tab before building".
And I bet that's why "restarting VS" sometime works. You see the "Error tab" is empty, you close and repoen VS, then, "Error tab" is shown by default as VS restored the current active tab from previous session. You build and now the "Error tab" gets populated...! You just got lucky.
Note: Reported a VS bug: https://connect.microsoft.com/VisualStudio/feedback/details/3132689
回答16:
Please check warnings. Sometimes build failed because of some kind of warnings too.
回答17:
Taken from this answer
Compilation failed, no errors were showed in the output window.
To try find the reason for the problem, I have changed the Build
Output in VS:
- menu "Tools - Options"
- from the left panel: "Projects And Solutions: Build And Run":
- change "MSBuild Output Verbosity" from "Minimal" to "Diagnostic"
After doing that, I found the real reason which was in fact a mistake with dependency projects. I project that I was depending on was built for different framework (newer) than mine. Thus creating the issue. The errors was only outputed when I put the Output Verbosity to Diagnostic
回答18:
For me, it was a rogue attached property. The problem wasn't necessarily that I couldn't see an error; the error was the following:
Child node "2" exited prematurely. Shutting down. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt.
Initially, the build would hang and not show any errors unless you attempted to close Visual Studio. After restarting, it would hang for a long period upon building, then display the above message.
Deleting hidden .vs
folder, rebuilding/cleaning solution, and restarting Visual Studio did not work. Removing the attached property did; ergo, it could be actual code somewhere that isn't working properly.
As a last resort, I would remove any recent changes one by one until the issue is resolved as none of the solutions here helped.
Update
Because I'm used to developing traditional WPF applications, I didn't realize you can't have "chained" XAML namespaces using .
s with UWP. I was attempting to set an attached property using
My.Namespace:SomeClass.SomeProperty="SomeValue"
Whereas, it should just be
MyNamespace:SomeClass.SomeProperty="SomeValue"
It's not as pretty as I like, but it's the only way to go, apparently.
回答19:
What worked for me:
Closing all documents solved the issue for me. (Same solution if intelliSense stops working)
(right click tab - Close All Documents)
回答20:
Try this
Excluding "mstscax.dll"
from the Dependencies worked for me.
回答21:
Niche issue: I ran into the same issue just now. None of the answers above seemed to help.
Issue was for a Console program, one cannot mark the Main() method as async** which is what I was doing. Not sure, why Visual Studio could not specify why exactly the project was not building (I got 0 errors and 0 warnings every time). I am using Visual Studio 2015 Enterprise.
Fix: The work around for that is here.
回答22:
For me the build failed without errors, but after some light investigation I found out that the refence to MSHTML wasn't found by VS.
The behavior appeared after an update to Windows 10. To fix it you need to register the assembly from the GAC. For how to do it, go to this answer MSHTML DLL on Windows 10 that's where I found my answer.
回答23:
After updating a dll file, it turned out that the new file was targeting a higher verion of .NET Framework. The solution was to go to Project Properties and change the Target framework to the appropriate version.
回答24:
You should set the combobox at right side under error list, on 'Entire Solution' to see all errors.enter image description here