Forcing Build to throw an error when dependency is missing - build

We use Visual Studio Team Services (was Visual Studio Online) to automatically build our code and deploy it afterwards.
Because we ran out of build minutes, we added a local build agent. After (sucessfully) building and deploying we received an error message on the final product.
It took us a while to add more logging, to find out, that a dependency was missing. (to be precise: Microsoft.IdentityModel, which is not a nuget-library)
We know how to add that missing library to the build machine.
But I would deeply prefer that the build itself already breaks and tell me that a reference is missing instead of just telling me: "Everything is fine" and ignoring the missing dll.
Is there a way to configure that?

Related

How do I properly configure SonarLint in Visual Studio Code for a CMake C++ project?

I'm working on a CMake C++ project in Visual Studio Code. I have the SonarLint plugin installed. Every time I save one of my source files, I get the error shown in the screenshot below.
When I click "Configure compile commands", I get another message stating that no compilation databases were found with a link to documentation on how to generate one. I followed the link and discovered that I can set the CMake variable CMAKE_EXPORT_COMPILE_COMMANDS to have it generate the database. However, setting that seems to have no effect since I still get the error after re-configuring my project.
What is the proper way to set that variable?
I'm doing this on Windows 10.

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.

MSBuild Different Results - One Errors, Other Succeeds

I have several Visual C++ projects (.vcxproj) that we have in a Visual Studio 2013 Solution. From a clean code pull, everything builds successfully in either Visual Studio 2013 or a build script that calls MSBuild on each project in the proper order (a relic from the days of old, which we are working, slowly but surely, to replace).
We have a few issues with this. First, if we build from the build script first, and then try to debug, it says that most of the projects are out of date. This is annoying, but I think this is due to the batch file not touching something in the intermediate directory the same that Visual Studio does. I find similar problems documented at Stack Overflow and Microsoft Connect. Is there an alternative to modifying the Microsoft.CppBuild.targets file? I'd like to have a fix for this that doesn't involve manually modifying all of the developer's machines.
The primary problem is: If we build a project from within Visual Studio 2013, it will build and link successfully. However, if we then go and build the same project from the build script, we get:
OtherProject.lib(SomeObject.obj) : error LNK2011: precompiled object not linked in; image may not run [Full path to .vcxproj]
OutputFile.dll : fatal error LNK1120: 1 unresolved externals [full path to .vcxproj]
Does anyone have tips on how to figure out which precompiled object this is as well as why the Visual Studio based build could manage to figure things out? Do I need to review every library dependency, and each of their dependencies? Is there an easier/automated way to do this? One thing to note is that Visual Studio 2013 does not always get it right and fails with the same warning.
Our batch file build command is:
msbuild /nologo /maxcpucount /clp:NoSummary /p:BuildProjectReferences=false /p:Configuration=Debug /verbosity:normal ProjectDir\Project.vcxproj

Change build settings in Xamarin Studio so that missing reference isn't interpreted as error

Is it possible to change the build settings in Xamarin Studio 5.5.3 so that some errors are interpreted as warnings? E.g. a missing reference is no build error anymore?
How can I do this?
A missing reference is always a build error. In the case of Xamarin, things like linking, AOT, compile to native, etc. can't be performed at all to create an application package.
You should include the missing DLL in your repository, so it is always there.
Or better yet, distribute it via NuGet so you can update it. You can host your own NuGet feed for this purpose or try MyGet.

Visual Studio Project always out of date, "up to date is missing #ECHO", why is Visual Studio looking for this input?

Background:
My team wants Visual Studio for development on an existing codebase, for its various tools, and that's what most developers are used to using. However, the existing build system (an internal flavor of Jam) is very entrenched, and for a variety of factors cannot be changed.
The idea:
Create a project for each component. I did this using a description generated by Jam of what files go into each library, and making that into a QT project file. I call qmake on this to generate Visual Studio projects with "qmake -tp vc".
Disable Visual Studio's build. I did this by changing the Type of each source file to "does not participate in build" (by changing each to )
Add a pre-build event that calls the Jam build.
Problem:
Now, when I try to build from Visual Studio, it works, in that it calls Jam.
However, I would expect Visual Studio to think the project is always up-to-date, considering it is not actually tracking any source files for compile. But it is always out-of-date, and must call the pre-build command before debugging (which attaches the debugger to the executable, and works just fine).
I used DebugView to see what was going on, and for many of my projects, I get the following in the log
[12900] Project '<my project's name>' is not up to date because 1 build inputs were missing.
[12900] devenv.exe Information: 0 :
[12900] up to date is missing: '<my project's location>\#ECHO'
I've searched high and low, but cannot find any reference to #echo as a file input to anything anywhere. Does anybody know, and/or is there a way to track down why it is looking for this?