VS2017 Error: The operation could not be completed - visual-studio-2017

I'm attempting to merge some code from a 3rd party. I thought I merged the source file ok as well as the .vcxproj files. To test out, I tried to do a compile of a single source file. It did a compile and failed with a message (don't remember what atm) and I addressed the error and tried to build that source file again. What I got was
1>Error: The operation could not be completed
Yes, not very helpful error message and I'm at a loss. I tried to delete the object files and tried again, I still get the same message. It doesn't seem even building anything. What can I do to get VS2017 to give me more helpful diagnostics? What could be causing this issue?

I got this error when moving a website from .net 2 to .net 4.6.1 which was hosted on local IIS7.5. It also showed as Visual Studio throwing all manner of errors upon loading the solution (pointing me at the not very helpful activity log)
All of my assemblies had been recompiled to .Net 4.6.1 and I'd changed the app pool to run .net 4 and integrated, however, VS seemed to think the web site should be loaded or compiled as plain .Net 4.0. This meant that it couldn't load the .Net 4.6.1 assemblies but didn't register this error just said it couldn't complete the operation.
I amended the web.config to add targetFramework="4.6.1" into the compilation element and it fixed it.

I just had this same error which drove me mad for hours. It turned out to be due to some sort of mix-up in the compilation configurations in the solution file, which made reference to configurations that did not exist (because the solution had been copied from another with more projects in it). What appeared to fix it was just going into the configuration manager dialog and then saving.

Related

QtMsBuild -> Qt::BuildLock

We have a fairly large solution (>200 projects) and recently switched to VS2019. We are using Qt 5.14 with Qt Visual Studio Tools 2.7.1.18 and QtMsBuild. After we started using VS 2019 we get the following warning multiple times when we build the solution:
"...\AppData\Local\QtMsBuild\qt_globals.targets(131,5): warning : Qt::BuildLock[{E42AFBC7-0C5E-441F-B1DB-AE4C9E75F86E}]: Waiting..."
The GUID is the GUID from one of the projects in the solution. Sometimes the build process even hangs up on the "Waiting..." but in most cases the warning does not seem to have an obvious effect other than that it is displayed.
My question is: Where does this warning come from? Why does it show? And how can we get rid of it?
I recently had a problem pop up seemingly out of nowhere. It's described in this issue: Visual C++ Builds Failing due to Log File Access Collision
Based on my investigation, Visual Studio appears to be redundantly building project dependencies instead of just referencing them, and when multiple projects with the same dependency build simultaneously, they will both hit a log file (or some other file) simultaneously, causing one to fail due to access restriction.
It seems that the QtMsBuild developers solved this by adding a CriticalSection task to the QtPrepare target preventing concurrent access. The downside is that this gets reported as a warning.

Visual Studio 2017 - Access Denied Error on Rebuild

I have a solution I created in Visual Studio 2017. All solution files are stored on a network location, accessed via a mapped drive. Up until earlier this week (April 10, 2018), everything worked fine. I could perform all required functionality.
Now, when I attempt to debug or build the release files, I get the following error:
Unable to copy file "obj\x64\Release\program.exe" to "bin\x64\Release\program.exe". Access to the path 'bin\x64\Release\program.exe' is denied.
The file is completely locked at this point. I can't do anything with it. I've done all of these suggestions found in other posts:
Make sure all instances of VBCSCompiler.exe are killed
Install the latest version of VS 2017
Install version 1.0.8 of Microsoft.CodeDom.Providers.DotNetCompilerPlatform
None of it works. I still get the error.
Now the real strangeness...
After I rebooted my machine the .exe file is removed from the release and debug folders. I can open the solution and rebuild the project successfully at that point, complete with a new, fully accessible .exe file. If I attempt to rebuild right away, with no changes made, the error shows up again.
I have to reboot my machine to release this file. That's hardly efficient.
If I copy the solution locally everything works fine. I don't have any issues.
I'm willing to move to working locally (as I'm sure it's a more advisable approach, but please spare me lectures on that topic) but I'd like to get to the bottom of this, if possible.
Thanks for any help you can offer...

VS compiling successfully when obvious errors exist after upgrading to framework 4.6.1

After upgrading my .net web project to use Framework 4.6.1 so that I can take advantage of c#6, I have experienced a problem building projects..
I say I have a 'problem' building, it's more like I don't have a problem building. It IS building successfully when in fact it should be failing! Take a look at the screenshot provided; web.config on the left, obvious syntax errors on the right, and a successful build below.
It builds successfully when I do a build / rebuild or run it in debugging; but does actually fail if I try to perform a publish.
Just to further, I have verified that the file that I am editing resides in the correct directory within App_Code, that I am building the correct project and have reset VS multiple times. I've tried to go through all school boy errors; but I think that as it successfully runs but throws a compilation error at that stage it is something down to the Roslyn compiler?
Also note, this is a freshly created project; All I have done is written some basic classes, upgraded the framework, and added a blank aspx page.
Recreating the solution file fixed this error.
Another cause could be down to the fact that I created the project as a WebApplication instead of a Website, but am unsure why this would cause successful builds with syntax errors.
Regenerating the solution with the project setup as a Website instead of a WebAppplication fixed the issue (although I had to change front-end control attributes 'CodeBehind' to 'CodeFile'; a difference between the two types of project).

Error code 31 returned from mt.exe when building C++ projects in Visual Studio 2013 [duplicate]

I ran into this problem today while migrating a VS2008 solution to VS2010. The problem occurred in either of the following scenarios:
Rebuild Solution
Clean followed by Build Solution
If I did a second Build after either of these, the problem did not show up. Using Google, all I really came up with was year-old blogs from Microsoft saying they are unable to reproduce the problem, or that it is fixed in a future release.
The best thing I found was here: Mikazo Tech Blog: Solve MT.exe Errors in Visual Studio 2010
In the above article it said that the problem is related to Manifest generation, and that the solution is to turn off Manifests in settings under Linker-->Manifest. I don't need Manifests for this project, but I still wasn't satisfied.
I have solved this, and am simply going to answer my own question, because I haven't found this specific error (code 31) on StackOverflow.
WARNING: This exact error can also happen as a result of having a Windows Explorer window open in the folder containing the *.exe which you are currently attempting to build.
For example: Explorer open in /.../MyProj/Debug/ while trying to build the Debug version of your code in Visual Studio.
I was angry with myself for ~10min before realizing this.
Using process monitor and dbgview I discovered msmpeng (Microsoft Security Essentials) was accessing the file, just when mt.exe wanted to have it exclusively. Excluding the development directory solved the problem.
It is still a workaround of course.
In my projects, the Intermediate and Output directories were set to:
Intermediate Dir : $(Configuration)\
Output Dir : $(SolutionDir)bin\$(Configuration)\
Under C/C++-->Output Files, I had the following:
ASM List Location : $(IntDir)\
Object File Name : $(IntDir)\
Program Database File Name : $(OutDir)\$(TargetName).pdb
Under Linker-->Manifest File, I had:
Manifest File : $(IntDir)$(TargetName)$(TargetExt).intermediate.manifest
The cure was to remove the trailing \ from my C/C++-->Output Files section (because it's already part of those variables):
ASM List Location : $(IntDir)
Object File Name : $(IntDir)
Program Database File Name : $(OutDir)$(TargetName).pdb
Normally, the double-up of using $(IntDir) or $(OutDir) with a trailing \ doesn't seem to cause trouble, even though it's bad practice. I can't remember now whether I did it by accident or if the conversion process did it, but for whatever reason, it seems to have been messing up MT.exe.
I hope this is useful to anyone else who encounters this problem. Your settings may well be different, but consider that it may be related to improperly formed filenames.
Try turning off Windows Defender (or possibly other anti-virus related software). Windows Defender is known to lock files because MT.EXE runs after the linker is finished. WD jumps in the middle to check up on the newly built EXE and locks it up for the MT.EXE.
Giving credit to https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/c5a3e2c3-fbf4-4268-a551-8cee195be586/test-case-13-for-vista-certification?forum=windowscompatibility, I found this was resolved by fixing the '-' character in the post build commandline. I believe some bad copy/paste efforts have replaced a hyphen with a dash.
deleting the "program debug database" in "debug" folder worked for me.
This problem happened when I was running the .exe in the debug folder on high priority.
Run VS as administrator. It solved the problem for me.
I have a project (*.sln) written in visual studio c 8.0. It was migrated to VC10 recently. When I choose the "Release mode", it was compiled sucessfully. But if I choose "Debug mode", the error " MSB6006 mt.exe code 31" happened.
I found that, in the debug mode, it used a wrong sub-project to startup.
After fixing the startup sub-project, it goes fine so far.
---- new status ---
This won't fix the problem. It just makes the problem disapear temporalily by rebuilding-all. Also, there are other faults caused by the migration. The "resources.h" is missed from the new project and the "winres.rc" is shorten.
In my case it was a problem with TortoiseGit. Removing Debug and Release folders from the GIT repository solved the problem.
Check if you have any anti-virus software like AVG. Exclude the manifest files in the anti-virus software exclusion list.
Look for an MSB8012 warnings. Likely you have a different output specification for the C++ output value and the Linker Output value.
Try Sysinternals/Procmon and filter on process = "mt.exe". It might tell you that a build input cannot be found.

VS2013 gets hung while compiling

I've a solution with ceratin no: of projects (all of them EXE projects in VC++).
I use VS2013.
This is tied to a version control system (Perforce).
I see that as soon as I start building any of the projects in this particular solution, the VS gets hung.
I see a text "Not Responding" at the top of the VS window.
Howvever teh compilation happens successfully but it takes a very long
time for the compilation due to this hang.
Id the expected compilation duration is "10seconds" it takes 3 mins to compile.
THis problem is seen in both Relaese and debug mode.
A point to note it that the very same projects were building super fast few days back & this issue started few days back.
Evevry other solution and it's projects (except this particular solution projects) are compiling very fast.
Any help is really useful.
You can also try to reset Visual studio settings trough:
Tools > Import and Export settings > reset all settings
this will reset all enviroinment settings, then restart visual studio.
edit:
I would also create a new project and copy/paste header and source files from old project to new one, and then compile.
I am not sure if you are using the P4VS Perforce Plugin with Visual Studio or not. However, there is a possibility that the compile is changing files that are checked into perforce or possibly somehow triggering an update. If you are using P4VS, please try building with it disabled and see if that
builds faster.
Try restarting your computer to see if that works. You may have some memory that was leaked from your program which is making it compile slower than usual. A restart of the computer should free all the memory.