Visual studio 2017 with Gtest showing string 'strncat' is not member of global sample Test-1 namespace - googletest

While project build once all dependencies resolved it is showing these string specific errors for string functions like strlen,strcat etc. so for that i have added string.h from project specific compiler folder but still not resoved. And the file in which this error persists it has string. included already.It doesnt seem project specific error rather visual studio specific.
I am using Visual Studio 2017 Professional Version.
Does anyone faced this issue.

Related

Visual Studio 2022 Unnecessary using directives and undifined type error at the same time

Is it just a Visual Studios bug?
I'm working with Visual Basic Project with Visual Studio Professional 17.4.3.
And it was no problem until last day when I open the solution,
Visual Studio showed a lot of errors with error code BC30002: Type '<typename>' is not defined.
But the sametime, the Type that errored was suggested by Visual Studio to remove Imports with warning code IDE0005: Remove unnecessary using directives.
The solution builds with no problem. It's just annoying to see..
I've tried Clean and Rebuilding, and deleting build files manually but I didn't worked.

Can´t build .net core project with a database project. Error MSB4019

I have a new .net Core 2.0 Web API project (In Visual Studio 2017 Version 15.3.5) where I can´t build the solution if I add a new database project.
error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.0\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
I have tried all kinds of solutions
Installed almost everything missing from the Visual Studio Installer
Installed Visual Studio Build Tools 2017
Repaired Visual Studio
Without luck I tried to find Microsoft.Data.Tools.Schema.SqlTasks.targets file on C:\ to the add reference to it in the project file (I then don´t know if that works while building the solution in VSTS).
So why can I add a database project to a normal API project and everything works just fine but not to a .net core one?
Do database projects not work with .net Core? I have searched for information on this but sorry I just can´t find it.
I´m not sure what to do. Hope somebody can help.
Ok I managed to find the Microsoft.Data.Tools.Schema.SqlTasks.targets file on my computer.
I then needed to unload the project and edit it
There I changed this line
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
to the hardcoded path of my file
<SSDTExists Condition="Exists('C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
And now it builds on my computer and on VSTS.
But why this is like this I don´t know.
I was having the exact same issue building a SQL Server project on an Azure DevOps CI/CD pipeline, and locally on VS Code. On Azure DevOps none of the pre-built build tasks would work for me, and locally I could only compile the SQL Server project on Visual Studio, which was annoying. Your solution didn't work for me, after doing what you suggest, I would get a .dll missing error, related with the first error.
I solved this by avoiding to add a SQL Server project to the solution.
I achieved this by using an MSBuild SDK, capable of producing a SQL Server Data-Tier Application package (.dacpac) from the set of SQL scripts. By adding this second project to the solution, I managed to continue taking advantage of linking the project to a live database through SQL Server Object Explorer on Visual Studio. I gave a more detailed explanation about my implementation in this answer.

msbuild fails to compile vsto project

We recently installed a new development environment (Windows 10) from scratch with Visual Studio 2017 but we cannot manage to make msbuild compile a Microsoft Office Addin for Word (vsto).
Within the Visual Studio installer we made sure to include the required components for Office Development.
It throws the following error (german translated to english)
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found. Also, tried to find "OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" [...]
However, the project builds fine within Visual Studio.
On the old system, everything works fine, and i cannot remember having to configure anything at all.
You need to install Office build tools when installing Build Tools for Visual Studio 2017
In my case, I managed to get around the issue by copying the folder
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio
from the development environment (the old environment in your case) to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio
on the build environment (the new environment in your case). I would have thought that one should be able to simply get the relevant targets from the Build Tools for Visual Studio 2017 but that appears not to be the case.
After reinstalling everything it works now.
I guess back then when we set up this machine, the build tools setup was bugged or something.
Now we could install everything we needed for the buildtools using the visual studio installer and it works like a charm.
Okay, so I've worked through this one now. The problem was caused by me using Windows\Microsoft.NET\Framework64\v4...\Msbuild.exe.
It looks as though running msbuild from this location results in it not being able to implicitly locate many of the assemblies and build utilities required to build a VSTO project.
I resolved the problem by switching to using C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe

Visual Studio 2015 - a lot of Packages are missing

So I recently bought a new computer. And now I wanted to install visual studio 2015. So I did. But now the problem is that i cant create a new project because i cant select a vb.net form or anything else and also im getting these error messages saying:
The 'ErrorListPackage' package did not load correctly
The'VisualStudioPackage' package did not load correctly
The Microsoft.visual studio package did not load correctly
anyone has a solution for this? because I'm kinda getting a bit frustrated now.
I tried a complete uninstall and install and it didnt work. I tried copying folders from my laptop to my new pc but also that didn't work. Also switching frameworks doesn't do anything. I also never experienced this problem before but can this problem occure because I have 2 drives?? Seems odd but I think I'm also going to do an uninstall again and then try the .iso installer and see if that helps.
So this is how I fixed it for myself.
I removed all files and folders that are linked to visual studio
C:\Program Files\Microsoft Visual Studio 12.0
C:\Program Files (x86)\Microsoft Visual Studio 12.0
C:\Program Files (x86)\Microsoft Visual Studio 14.0
C:\Users\name\AppData\Roaming\Microsoft\VisualStudio
C:\Users\name\AppData\Local\Microsoft\VisualStudio
C:\Users\name\AppData\Local\Microsoft\VisualStudio Services
C:\Users\name\AppData\Local\Microsoft\VSCommon
C:\Users\name\AppData\Local\Microsoft\VsGraphics
After I deleted all of those folders I deleted the regkeys located:
HKLM > SOFTWARE > Microsoft > Visual Studio
After that I started the visual studio installer with admin rights.
And now I can create a project :)
This usually indicates an issue with an extension which ships with some dependent assemblies which Visual Studio itself (or another extension) also depends on. When these dependencies are different versions, it's not predictable which version will load.
To solve your problem, first disable your extensions and add-ins, then close Visual Studio, clear the ComponentModelCache folder under:
C:\Users\{username}\AppData\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
And start Visual Studio again.
This should clear the immediate issue.
Now enable each extension one-by-one restarting Visual Studio every time to see if the issues come back.
To dive deeper into the underlying issue, you could look into all the extensions under these folders:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions
C:\Users\{user}\AppData\Local\Microsoft\VisualStudio\12.0\Extensions
Look for assemblies from Microsoft itself (commonly found are Microsoft.TeamFoundation.* and Microsoft.VisualStudio. in folders containing an extension that did not originate from Microsoft. These extensions are common culprits for these issues.
If you want to dig deeper, consider using fuslogvw from the Windows SDK to see which assemblies are loaded and which exact versions they are. You can also look into the Visual Studio logs after the issue surfaces to see what underlying cause there may be. The log should be available under:
%AppData%\Microsoft\VisualStudio\14.0\ActivityLog.XML

Why does my build app fail when run outside of VS12 (i.e. when deployed)?

I've written a c# program that builds *.csproj and *.vcxproj using Microsoft.Build.Evaluation. It works great on both project types if I compile and run it from inside Visual Studio 12. But if I run the exe directly (outside of Visual Studio) I get the example error message below. The error occurs only for vcx projects; c# projects continue to build just fine
Question: Why am I getting this error? Why does my program work fine for both C# and vcx projects when run from within VS12, but fails, but only for vcx projects, when run outside of VS12?
Please don't chastise me for not using MSBuild.exe. My orders were to programmatically build C# and vcx projects using Microsoft.Build.Evaluation.
Code:
using Microsoft.Build.Evaluation;
...
Project proj = new Project("MyCppProject.vcxproj");
proj.Build(logger);
Runtime Error:
Building MyCppProject
Project "MyCppProject.vcxproj" (default targets):
VCMessage:
ERROR C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(518,5): Specified platform toolset (v110) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected.
Done building project "MyCppProject" -- FAILED.
One solution is to force the Visual Studio version as an environment variable prior to loading and building the project:
using Microsoft.Build.Evaluation;
...
Environment.SetEnvironmentVariable("VisualStudioVersion", "11.0")
Project proj = new Project("MyCppProject.vcxproj");
proj.Build(logger);
Visual studio maintains platform tool sets list supported for the version of Visual studio you are currently running for example on my machine I have VS 2008, 2010 and 2012
Now suppose when I install Visual Studio 2013 which has a Platform Toolset version of V120. What happens, is that the project saves this in its corresponding XML files in the format (vcproj, vcxproj, vcxproj.filter.user files).
now this valus is not known to VS 2012 so it complains when opened in VS 2012.
Similarly for opening VS 2012 project in VS 2010, as in your case and so on.
Solution:
To fix this issue, Open you solution file in notepad++.
Make these 2 changes
1) Replace
Format Version 12.00
with
Format Version 11.00
2) Replace
Visual Studio 2012
with
Visual Studio 2010
Then open the file again in visual studio and rebuild solution.