Visual Studio 2010 and TFS 2008: Building unit test projects - unit-testing

We are currently taking VS2010 for a testdrive and so far we are a little stumped with how it just won't cooperate with our existing Team Foundation Server 2008.
We still have all our projects on .NET 3.5 and whenever we are now building a solution that contains a unit test project (which automatically builds in .NET 4.0) the TFS won't build it.
The .NET 4.0 framework is installed on the TFS 2008.
The error we're receiving is:
[Any CPU/Release] c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(0,0): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
As a temporary workaround we are now forced to remove all our test projects in order for our solutions to build.

You need to install VS2010 on your build machine.

I'v just been trying to build V4.0 solutions on TFS2008, and altered the C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\tfsbuildservice.exe.config file:
<add key="MSBuildPath" value="" />
to
<add key="MSBuildPath" value="c:\Windows\Microsoft.NET\Framework\v4.0.30319\" />
The build of v3.5 and v4.0 solutions did succeed. But the unittest of the v3.5 solutions did not work.
Read about installing VS2010 on the build server, but read somewhere else: ( http://www.richard-banks.org/2009/11/how-to-build-vs2010-solutions-using.html ) that it is possible without installing VS2010.
: Text from that website:
This worked for us allowing a TFS 2008 build agent compile VS 2010 solution/project files without installing VS 2010:
Install .NET Framework 4.0 and .NET Framework 3.51 SP1 (for some reason, SP1 wasn't included with 4.0?)
Install Windows SDK 7.0A. When I'm writing this the SDK is still not released so we had to:
From a computer with VS 2010 installed, copy the SDK folder from %programfiles%\Microsoft SDKs\Windows\v7.0A and registry settings from HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\7.0A to the build machine.
Copy %programfiles%\MSBuild\Microsoft\VisualStudio\v10.0 to the build machine
Change ToolsVersion from 3.5 to 4.0 in your TFSbuild.proj file.
I think that was all. There was no need to change the build agent's configuration file.
Hopefully this will work.

Install "Agents for Visual Studio 2012"
http://www.microsoft.com/en-us/download/details.aspx?id=38186

Related

The module "%VSINSTALLDIR%\DIA SDK\bin\msdia140.dll" failed to load, while trying to install llvm on windows 10

I am trying to get started with compiler development using llvm, I follow official setup page on the 10th step and am getting the following error
The module "%VSINSTALLDIR%\DIA SDK\bin\msdia140.dll" failed to load make sure the binary is stored at specified path or debug it to check for problems with binary or dependent .DLL files. The specified module could not be found.
Visual Studio 2022 information :
Microsoft Visual Studio Community 2022
Version 17.1.6
VisualStudio.17.Release/17.1.6+32421.90
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA606
Microsoft Visual C++ 2022
ASP.NET and Web Tools 2019 17.1.363.30963
ASP.NET and Web Tools 2019
Azure App Service Tools v3.0.0 17.1.363.30963
Azure App Service Tools v3.0.0
C# Tools 4.1.0-5.22165.10+e555772db77ca828b02b4bd547c318387f11d01f
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
NuGet Package Manager 6.1.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
TypeScript Tools 17.0.1229.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.1.0-5.22165.10+e555772db77ca828b02b4bd547c318387f11d01f
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
I am trying to get llvm up and running, The .dll files are available at the given location, please help.
$ ls
amd64/ arm/ arm64/ msdia140.dll*
I had the same problem as you at first, please read my solution carefully:
You need to use the cd command to enter the folder where you want to install LLVM. Regarding the cd command, I suggest you search for usage methods on Google, I believe it will be easier to understand than what I described.
The documentation mentions that You may install the llvm sources in
other location than c:\llvm but do not install into a path containing
spaces (e.g. c:\Documents and Settings...) as it will fail.
Run the Developer Command Prompt for VS 2019 as an administrator.
Enter regsvr32 "%VSINSTALLDIR%\DIA SDK\bin\msdia140.dll" to get the following result.
Please look carefully at Figure 1.

All Unit Test projects in TeamCity does not compile failing to reference Microsoft.VisualStudio.QualityTools.UnitTestFramework

All our unit test projects (About 8 of them) just stopped compiling and I can't find any good reason for it.
"error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"
From the TeamCity (v2017.2.2) build log the projects are missing the Microsoft.VisualStudio.QualityTools.UnitTestFramework DLL with error codes CS0234 and CS0246. I can't see any code changes that could have caused it
there was however a server restart that might have kicked in some pending changes.
What has been checked
Checked both with a Visual Studio (SLN) and MSBuild runner step, both gave the same results (MSBuild was previously working fine while the Visual Studio was failing on the C# 6/7 code, the reason why we changed to a newer MSBuild version)
These Test projects build fine on the same build server if the solution is opened in Visual Studio 2017 Enterprise (Installed on Build server)
Project Reference configuration
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
MSBuild Version
We use the MSbuild v15.6.82.30579 in Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin not the default one in C:\Windows\Microsoft.NET\Framework64\v4.0.30319 (Added as such to environmental variables)
Any recommendations will be appreciated. I really don't want to start adding DLL's to the GAC if it can be helped.
If you are using Build Tools 2017 on your server, and you don't have Visual Studio 2017 installed, then you have to switch to MS Test v2:
https://blogs.msdn.microsoft.com/devops/2017/09/01/upgrade-to-mstest-v2/
https://www.nuget.org/packages/MSTest.TestAdapter
https://www.nuget.org/packages/MSTest.TestFramework
Old MS Test framework is not supported with Build Tools.
Then in TeamCity in Build Step you have to change your runner type to Visual Studio Tests, Test engine type from MSTest to VSTest, and Test engine Version to VSTest 2017
Install "VC++ 2017 version 15.7 v14.14 toolset" component under individual components, seems that the default toolset does not have the unit test binaries.
References:
Unit test files not installed by Visual Studio Build Tools 2017
Okay so the issue seemed to be broader than just Unit Tests. In short even though MSbuild and Visual Studio build (from the build server) running MSBuild step from Visual Studio does not utilize the same 'shared' folders.
I had to make use of a couple of different strategies to sort out version and missing common DLL's:
Update the Visual Studio Build Tools to the latest version i.e. get the latest version of MSBuild to the build server and ensure it is added to the OS environmental PATH (Set the default MSBuild to be the new one). In my case it was changing it from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319' to 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin'
Add the missing/newer DLL to the MSBuild BIN folder and mark it as read-only so that it is not overridden again
As last resort you add the DLL to the GAC using the gacutil.exe. This is not recommended because it obfuscates the relationship (Rather try to find where it is used with Fusion logging and add it there).

What do I need to install for C++ project / VS 2013 on TeamCity server or Team Foundation Build Service?

I am attempting to build a C++ project in a Visual Studio 2013 solution on TC 8.0.6 (build 27767).
I have installed the latest MSBuild "Microsoft Build Tools 2013" stuff (which is normally installed as part of VS 2013 install) directly on the server.
But I get the following error:
[17:05:23]VCTargetsPath is c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\
[17:05:23]PlatformToolset is v120
[17:05:23]VCMessage
[17:05:23]c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32
Microsoft.Cpp.Win32.Targets(512, 5): error MSB8008: Specified platform toolset (v120) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected.
[17:05:23]Project MyCppProject\smCpp.vcxproj failed
As far as I can see I have everything I need and I have tried various hacks to set the PlatformToolset to v110 etc., but that doesn't work either.
At this stage I would like to verify exactly what I need to install on the build server. Can someone clarify if I need anything extra please?
Many thanks
Brian
Ultimately you need to set the correct path to MSBuild. With VS 2013, build tooling became part of VS rather than .NET, making it version 12.0 instead of 4.0. The default path in this instance is:
"C:\Program Files (x86)\MSBuild\12.0\bin"
If the team foundation build is broken then it's likely because the TF server is not on version 2013. To fix the problem you need to make yourself a copy of the build template the build definition uses (assuming your version is >= 2010 and < 2013) and point to the correct tooling folder. The build templates are located in the following source path:
$/YourTeamProjectName/BuildProcessTemplates
If you can edit the template in Visual Studio you open the Workflow Foundation design surface. In there find the Run MSBuild for Project tasks (note in the default template there is more than one, but I've shown a pic of what to look for) and change the tool path property to the above path.
Once you created the template you need to change your build definition to use the new template.
For TeamCity you need to set the MSBuild ToolsVersion to version 12.0 in your build step. I'm not sure what version of TC started support for version 12.

Does MSBuild need Visual Studio to be installed?

I'm setting up a build server using Atlassian Bamboo. MSBuild is included with the .NET framework, so I believe I can build .NET applications fine at least without VS2010.
We mostly develop in C++ - will I need to install Visual Studio on the build server to build .vcxproj C++ projects, or can this be done only with MSBuild?
No you just need the toolset (libraries) see: http://msdn.microsoft.com/en-us/library/dd293607%28v=vs.100%29.aspx

Building C++ CLR app for Platform Toolset v90 in VS2010 requires Visual Studio 2008

I've got a shiny new laptop with the latest Dev tools installed such as Visual Studio 2010.
Now I've got a task to build a C++ CLR app targeting the 2.0 runtime (this is well outside my comfort zone). So I've specifed the v90 Platform Toolset but when I build I get:-
error MSB8010: Specified platform toolset (v90) requires Visual Studio 2008. Please make sure that Visual Studio 2008 is installed on the machine.
Seriously, do I really need to install 2008 as well? Is there some way round this, such as just copying in some folders from a 2008 install?
If not just how much of the VS 2008 installation do I need?
Part of the problem is that VS2010 redid how compiling in c++ (cli or not) works. It now uses the MSBuild structure but I believe what you are trying to do will need the VCBuild framework that is not in 2010.
You may be able to get away with using the Visual Studio 2008 express to build. If not you should only need the c++ portion of VS2008.
Do you need to use the vc90 target though? I build my c++/cli (still new myself) with the vc10 target and it builds fine. (however i am targeting the 4.0 framework referencing some 2.0 portions)
If you set the 'Platform Toolset' in general tab of your project settings to "inherit from parent or project defaults" it will work in most of the cases.
in *.vcxproj
<PropertyGroup Label="Globals"> //Globals
<ProjectGuid>{E0047D4D-366D-4870-980B-DBB5A375BCE2}</ProjectGuid>
<RootNamespace>ECGConvertWrapper</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> //there
</PropertyGroup>