Visual Studio messes up project settings - c++

I've created an empty C++ project, added main.cpp, and set up build configurations. Particularly, I changed Output Directory and Intermediate Directory. Pushed everything to GitHub, and cloned it to the other computer. Opened solution, checked properties of the project to find out that it is now set back to default. Tried compiling, wrong directories are used. git status on both computers shows nothing. I also checked .vcxproj to find out that changed strings are present in the file.
What could be the cause of this behavior?
Repository: https://github.com/kirdaybov/experiments
My environment:
1st computer: VS Express 2015 update 1.
2nd computer: VS Community 2015 update 3.

This happens to me all the time!
VS has the nasty habit of not saving project and solution options, even when you configure it to "Save to Compile", or even when you click the "Save" button.
You must click the "Save All" button. Or to be extra safe, close VS before committing.
Or could be caused because one of the computers is compiling the "Debug" configuration while the other is compiling the "Release" one. Or one is compiling the "Any CPU" and the other the "x86". Note that the "current configuration" option is not pushed to the repository.

Some updates MIGHT change libraries directory. I had this moment when I changed from VS2015 to VS2017 and nothing worked anymore.
Also try to see the directories in the settings. A project could be on CPU1's desktop, but on CPU's 2 document folder. In other words, check project propreties.

Related

Visual studio compiling failed without any errors [duplicate]

I have a WebApplication which contains reference to WCF services.
While building using Visual Studio 2010, Build fails without any error or warning. However building the .csproj using MsBuild is successful.
Can't figure out what should I try in Visual Studio, to resolve / diagnose the issue. Can you please help out?
I find out that the build has been failing,
From text displayed in status Bar.
From output window:
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
The output tab includes configuration details.
------ Build started: Project: <projectName here> Configuration: Debug Any CPU
I noticed that if "Build + Intellisense" is selected in the Error List, it causes the error messages to be swallowed.
Change this option to "Build Only", and all error messages will be displayed:
I don't know if this is a bug in Visual Studio or what, but it certainly revealed hidden error messages that were the key to pinpointing the failure for me.
Some, like Richard J Foster, have suggested increasing the "MSBuild project build output verbosity" setting to "Diagnostic" (the highest possible option), but this didn't solve the problem for me, as Visual Studio appeared to be suppressing the error message(s) themselves.
As an alternative, you may try to use the raw output messages from the "Output" tab, which haven't been filtered by Visual Studio. Either do an in-place search for the strings "error" and/or "failed", or copy all of the output to your favorite text editor and do a search there.
To ensure that the Output window appears each time you do a build, you can go to Tools → Options → Projects and Solutions → General, and ensure that the option "Show Output Window when build starts" is checked.
As an additional troubleshooting step, it is also possible to build the project from the PowerShell command line by running dotnet build. This will show you the complete build output, including any errors that Visual Studio may be hiding.
I just ran into a similar situation. In my case, a custom action (from the MSBuildVersioning package available on Nuget.org - http://www.nuget.org/packages/MSBuildVersioning/) which appeared in the csproj file's BeforeBuild target was failing without triggering any error message in the normal place.
I was able to determine this by setting the "MSBuild project build output verbosity" (in the latest Visual Studio's Tools tab [Path: Tools > Options > Build and Run]) to "Diagnostic" as shown below. This then showed that the custom action (in my case HgVersionFile) was what had failed.
Here are some things that you can try:
If your solution contains more than one project, try building each project one at a time. (You may even want to try opening each project independently of the solution.)
If applicable, ensure that all of your projects (including dependencies and tests) target the same version of the .NET Framework. (Thanks to user764754 for this suggestion!)
Tip: Check Tools → Extension and Updates to ensure that your packages are up-to-date.
Ensure that all dependency projects are built to target the same platform as your main project.
Try restarting Visual Studio.
As suggested by Bill Yang, try running Visual Studio as Administrator, if you aren't already. (If you are already running Visual Studio as Administrator, perhaps try the opposite?)
Try restarting your computer.
Try "Rebuild All".
Run "Clean Solution", then remove your *vspscc* and *vssscc* files, restart Visual Studio, and then "Rebuild All".
As suggested by Andy, close Visual Studio, delete the .suo file, and restart Visual Studio.
As suggested by Arun Prasad E S, close Visual Studio, delete the .vs folder in your solution directory, and then re-open Visual Studio. (This folder is auto-generated by Visual Studio and contains cache, configuration settings, and more. More details can be found in these questions: Visual Studio - Deleting .vs folder and https://stackoverflow.com/q/48897191.)
As suggested by MrMalith, close Visual Studio, delete the obj folder in your solution directory, clear your temporary folder, and then re-open Visual Studio.
Delete the hidden .vs folder & restart Visual Studio. That worked for me.
I want to expand on Sasse's answer. I had to target the correct version of .NET to resolve the problem.
One project was giving me an error:
"The type or namespace name 'SomeNamespace' does not exist in the namespace 'BeforeSomeNamespace' (are you missing an assembly reference?)".
There was no error in the Error List window but the assembly had a yellow warning sign under "References".
I then saw that the referencing project targeted 4.5.1 and the referenced project 4.6.1. Changing 4.6.1 to 4.5.1 allowed the overall build to succeed.
Nothing was working for me so I deleted the .suo file, restarted VS, cleaned the projected, and then the build would work.
I tried many things like restarting Visual Studio, cleaning and rebuilding the solution, restarting the PC, etc., but none of them worked for me. I was finally able to solve the problem by doing the following:
First of all, make sure all the projects in your solution (including tests) are targeting the same .NET version. Then:
Save pending changes in the project and close Visual Studio
Find the exact location from file explorer and find "obj" file and open it,
Then, delete all the included files (some files won't remove, it doesn't matter, just skip them).
Use run command (by pressing Windows Key + R) and type "%temp%" and press enter to find temporary files.
Finally, delete them all.
On other possibility is that Visual Studio needs to run as Administrator, this might be related to deploying to local IIS server or other deployment need.
Just for the sake of completion and maybe helping someone encountering the same error again in the future, I was using Mahapps metro interface and changed the XAML of one window, but forgot to change the partial class in the code-behind. In that case, the build failed without an error or warning, and I was able to find it out by increasing the verbosity of the output from the settings:
In my case (VS 2019 v16.11.20), disabling Text Editor->C#->Advanced->Enable 'pull' diagnostics in the options solved the issue.
Double check for _underscore.aspx pages in your project.
I had a page and code-behind:
`myPage.aspx` and `myPage.aspx.vb`
when building the project, I'd get errors on the .aspx.vb page stating that properties defined on the .aspx page didn't exist, even though the page itself would build fine and there were NO OTHER ERRORS showing in the output (even with diagnostic level build output).
I then came across a page in the project that was named the same thing but with an underscore: _myPage.aspx - not sure where it came from, I deleted it, and the solution built fine.

Visual Studio 2017, Intellisense is not working

I just upgraded from VS2015 to 2017, and intellisense highlighting of syntax errors has disappeared completely.
I tried some suggestions found online, mainly Edit->Intellisense->Refresh Local Cache, but that option is not there anymore.
Under Edit->Intellisense there is only Quick info which does nothing when I press it, and toggle completion mode which is greyed out
I'm using Windows 10, C++ project.
Do I need to delete some old files from VS2015 in order for intellisense to work again? like the VC.db file?
Thanks
When IntelliSense stopped working in some files, I just deleted the project cache, restarted Visual Studio and opened the project again. Bear in mind that some minor settings also get reset (like the selected architecture).
Step by step
View => Solution Explorer (in case it isn't already open)
Right click "Solution 'Project name'"
Click "Open Folder in File Explorer"
Close Visual Studio
Show hidden folders (Win10 How-to)
Delete folder ".vs"
Open Visual Studio and project (wait a few seconds)
Hope this helps. -Minding
If you encounter a file in which the intellisense or error list is not functioning properly, look at the top-left corner of the navigation bar and check to see if that file is marked as “Miscellaneous Files”
If it is, the steps to solve the issue is:
Go to the file inside Solution Explorer.
Right-Click file and select Exclude From Project.
Right-Click your project/folder where the file was and click Add Existing Item, and add the file you just removed back into your project.
This should fix whatever issues you're having. (Tip: You can multi-select source/header files, so this does not need to be done one at a time).
Right-click on solution and select Rescan Solution (Visual Studio 2017). This should re-sync IntelliSense with solution data.
Please try to click Tools->Text Editor->C/C+±>Advanced, under IntelliSense, set
Member List Commit Aggressive to True and recheck this issue. Also, set
Use Aggressive Member list for Auto Member list to *False.
In my case, the project was referring to 2 different versions of the same library. I uninstalled one of the versions and intellisense started working.

How can I install/configure OpenCV3.2.0 with C++, Visual Studio 2017?

I want to use OpenCV in Visual Studio 2017 to do c++ program.
To do it, I followed Setting Up OpenCV in Visual Studio video. In that, he said vc14 should be set as environmental variables for VS2015. There is no vc16 for VS2017. So how do I do it for VS2017? And are there any other video instruction changes to be made if I am to use VS2017?
Since the Doc from official OpenCV tutorial is outdated, I will suggest:
get VS-2017 with full compiler like:
get the newest CMake (uninstall older versions)
get from github the sourceCode here and here and place those in C:/openCV folder, create a BUILD folder there too
open Cmake, select the opencv master folder... in the build write the build directory like:
click configure, select visual studio 15 2017 and leave selected "use default native compilers", then press "finish"...
6.1 now you should see cmake doing its job :)
once configuration is done set the opencv extra modules path and click configure again, and when is done click generate! :)
when generation is done click "open project", this will open a huge project in visual studio named "opencv", now you can close cmake, we dont need that anymore.
now, when the solution is ready, be sure you are in "debug" conf and do right click on "ALL_BUILD" and then "build" (that can take a while) once build succeed change to "release" config and do right click on "ALL_BUILD" and then "build" again.
now,be sure you are in "debug" conf and do right click on "INSTALL" and then "build" (that can take a while) once build succeed change to "release" config and do right click on "INSTALL" and then "build" again.
Additonal tip to the accepted answer - if you get an error like this:
Invalid escape sequence \ o
when you copy and paste the filesystem paths, make sure you use forward slash ( / ) instead of backward slash, so
C:\openCV\opencv_contrib-3.2.0\modules
Must be
C:/openCV/opencv_contrib-3.2.0/modules
Instead. Otherwise, you will get errors that escape sequence \o does not exist.
Previous post is just perfect. VS 2017 has lib version VS141.
Just extension of previous.
8 Step. After the cmake generate the Opencv.sln in build folder. Open this project in VS 2017
I am using approach first, just DEBUG x64 version
The output looks like this
After Debug, switch to Release and Build whole solution again.
Same for 32 bit version. Your final solution is under install location under build folder. With contrib libs whole process took almost 30 minutes on I7. Just shaking with CMAKE until the zero defects, include what ever FFMPEG, Contrib and other path. Final build in VS 2017.
The whole approach and install of built libs you can find on my blog Here

How to separate the dev and production *.sln for Visual Studio 2013 projects

I've set up my application release process on Jenkins CI. The build command is:
"c:\Program Files (x86)\Microsoft Visual Studio
12.0\Common7\IDE\devenv.com" foo.sln /Rebuild "Release" /Out log.txt
The optimization flags (/LTCG /OPT:REF /OPT:ICF) are enabled in foo.sln.
When I development on my machine, I would like to disable those flags (so incremental build is available) in order to reduce the build time. My problem is I have to check out foo.sln from version control system (Perforce in my case), disable the flags. However, whenever I need to check in any changes to foo.sln, I have to toggle optimization flags before check-in and after submitted. So my local settings won't get checked in. Is there a way to make this process easier (avoid toggling the local settings)?
I found some similar questions on SO, but those are for Web.config/App.config. Not for foo.sln solution files.
Using different Web.config in development and production environment
How to select different app.config for several build configurations
A VS solution starts with two standard configurations, Debug and Release. If you need another one and Debug isn't good enough then just add it.
Use Build + Configuration Manager. Upper left combobox marked "Active Solution Configuration", pick "New". Give it a distinctive name and copy from Release. Change the settings you want to be different. Alter your build command accordingly.

Visual Studio 2010 not rebuilding/recompiling

I was working on a project when all of a sudden VS stopped recompiling my project each time I debugged (mid way through working... I never changed anything). So it keeps running the same old build over and over.
I don't want to have to "clean build" each time, and I've followed the instructions here (Visual Studio 2010 doesn't rebuild changed code unless I manually select "Rebuild"). Surprisingly, they were already set (prompt to build when project outdated, build is checked under configuration manager).
However, it still never prompts me (except for after clean), and it's getting really frustrating. I'm using VS c++ if it helps.
I just had the same issue. This might solve your problem:
Tools->Options->Project and Solution->Build and Run.
There is an option what to do for "On run, when projects are out of date". Set this to "always create". This will mean that if you compile a project which depends on another project in your project folder, then the other project is compiled first, just as you want.
In my case, this option was set but then set to something else after a crash of VS2010.