可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have an MVC project that for an uknown reason refuses to publish to a local folder in the PC.
The log says the following:
3>------ Publish started: Project: Admin, Configuration: Release Any CPU ------
3>Connecting to D:\Deploys...
3>Project "Admin.csproj" (GatherAllFilesToPublish target(s)):
3> Building with tools version "14.0".
3> Target "ValidateMSBuildToolsVersion" skipped. Previously built unsuccessfully.
3>Done building project "Admin.csproj" -- FAILED.
3>
========== Build: 2 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
I haven't had a problem debugging on either release or debug config.
回答1:
So I made it work.
The problem was the version of the "Microsoft.Net.Compilers". I downgraded from v2.6.1 to v2.4.0.
I don't know why so if someone knows it would be cool to know.
回答2:
Sorry for reopening the thread, but for me Cleaning the solution worked on .NET.Compilers v2.7 (Visual Studio 2015).
回答3:
downgrade "Microsoft.Net.Compilers" from v2.9.0 to v2.4.0 works like a charm
回答4:
I was able to resolve my issue altogether by removing the NuGet package "Microsoft.Net.Compilers", rather than downgrade to 2.4.0.
(For quite some time, the Publish error would disappear if I simply restarted VS, but eventually that stopped working.)
回答5:
First, select the mode (Debug or Release). Then right click on the solution/project then select Clean. Then choose Rebuild. Then Publish.
回答6:
This just happened to me, it turned out to be a simple case of using an int in a ViewComponent call from a razor template, when that argument should have been a Guid. For some reason Intellisense didn't pick it up, I had to turn on detailed verbosity to see the error in the build process.
回答7:
I had this problem in Asp.net Core 2 MVC 2.1
So there was no Microsoft.Net.Compilers in my solution. I tried to rebuild all projects, unload / load again but there was no change.
1) So, I have upgraded VS 2017 15.7.3 to 15.8.7
2) Then deleted all bin/release directory contents from each projects in solution.
3) Then deleted all obj directory contents from each projects in solution.
4) Then rebuilded all projects one by one.
Then tried to publish and it succeded.
Maybe if I tried from step 2 in old Visual Studio it would be succed.
回答8:
Try opening the solution with Visual Studio 2017
I had been building and publishing from Visual Studio 2015, as that is the version of Visual Studio that the Version Selector picked when I opened the solution file.
I tried opening my solution file from Visual Studio 2017 instead, and that succeeded in publishing.
回答9:
I had switched to C# 7.3
in Properties > Build > Advanced, but accidentally only did so for the Debug configuration. When publishing (using Release configuration) it was still using C# 7.0
, which lacked some of the language features I had used.
Errors weren't visible in the Error List pane, only in the Output pane.
Setting the language version to C# 7.3
for "All Configurations" solved it for me.
This was using current version of Visual Studio 2017, Microsoft.Net.Compilers
package not included in project.
回答10:
Try removing the Microsoft.Net.Compilers
Nuget package.
I had tried a lot of things, none successful. I did this and the publishing succeeded. To be sure, I restored my project from BitBucket to its original condition, tested to see the publishing failed, removed the nuget package again, and it worked.
回答11:
I had a similar problem. The project was building okay but when I published it Azure send me errors.
My project target .NET framework was 4.6.2 version and I was upgrading Nugget packages, unfortunatelly I upgraded my .NET Compilers to last version and it wasnt compatible to my target .NET version.You should be able to see it here:
Description of .NET Compilers
My target framework
I fixed it by downgrading .NET Compilers to a version compatible to my .NET Framework (In my case, to use 4.6.2 framework I need to use .NET Compiller 2.10).