TFS 2012 + VS 2013 + Microsoft Fakes compile issue (only during TFSBuild) - tfs

We are using TFS 2012 (Update 3) and VS 2013 RC. We have a .sln file with a two projects - the main project / assembly, and a UnitTest project. The unit test project is leveraging Microsoft Fakes. Within Visual Studio (we are using Premium), I can compile the .sln and run the tests. On the build agent, I can use Visual Studio to compile and build the .sln and run the tests. But when we queue a build, it fails to build the UnitTest project because it can't find the Fakes assembly. It doesn't appear to be dynamically creating it like it does when you build in Visual Studio. Typically in VS is creates the fakes dll and puts it in the FakeAssemblies folder. After the build fails, I can log in and see it did not create a FakeAssemblies directory at all.
The error is...
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1605): Could not resolve this reference. Could not locate the assembly "System.Web.Http.5.0.0.0.Fakes". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Our build is using the default template - and we have selected to build the .sln (which has the main assembly and the unit test project). Should we not be including the UnitTest in that .sln? Is there some other way the UnitTest should be getting compiled during the build?
Does anyone know why the build wouldn't by creating the Fake assembly dynamically like Visual Studio does?
Thanks!!!

I had the same issue but with TFS 2012 and VS 2012 and solved it by installing Visual Studio in TFS Server. So if you've already installed VS there, this advice won't help you.
First, I tried to copy that assembly from the folder in my local machine to the same folder in the TFS server. It's located in c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.QualityTools.Testing.Fakes.dll.
The problem was solved, a test project was built successfully, but each test that were using Fakes were not passed. There was an exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException:
UnitTestIsolation instrumentation failed to initialize. Please restart
Visual Studio and rerun this test.
I did not have time and decided to make the second step and installed Visual Studio in TFS machine and all problems disappeared

Related

TFS How to Build Visual Studio-based "Open Folder" CMake project

I have an ARM-GCC project, which is configured and built using Visual Studio's native "Open folder..." CMake project support (introduced in VS2017). All of our needed build settings are stored in CMakeSettings.json.
I would like to build this project using our TFS Continuous Integration server.
I've confirmed that our build server contains all of the prerequisites provided 'out of the box' by the Visual Studio 2017 installer - CMake, Ninja, and ARM-GCC compilers. These tools are all installed to a 'standard' Visual Studio tooling location:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Linux\gcc_arm
etc.
These tools 'just work' out of the box, when we open the project using Visual Studio's "File" -> "Open Folder..." approach. Within TFS however, we can't seem to get the solution to build. I've tried a few different approaches within the build definition...
Option 1: 'Visual Studio' task
This approach complains about a missing sln/proj file:
Specify a project or solution file. The current working directory does
not contain a project or solution file.
There is no project or solution file, because it is an "Open Folder" project, with a CMakeSettings.json file, instead...
Option 2: 'MSBuild' Task
I have not found a set of command-line options capable of building a CMake project folder, using MSBuild.
Option 3: 'CMake' Task
When adding a CMake task to the build definition, the build server complains that it does not fulfill the auto-generated "cmake" ability prerequisite, despite the fact that Visual Studio has installed the cmake tool.
Has anyone successfully completed a TFS automated build of a Visual Studio-hosted "Open Folder..." CMake project?

F#, Visual Studio 2017 and dotnet new

To create a .NET class library from the command line, you can run the script
dotnet new classlib
Do that in a clean folder, and it will create a csproj file that can then be opened in Visual Studio 2017.
However, run the script
dotnet new classlib -lang f#
in a clean folder, and the fsproj file that is subsequently create cannot be opened in Visual Studio 2017. The error message reads
The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\FSharp.NET.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
I have searched for clarification of this issue, and it appears that there is work ongoing to fix it, but I wondered in the interim if there are any add-ins I can install to get this working immediately.
The latest preview releases of Visual Studio and .NET Core support loading .fsproj projects, apparently.
See this comment on the GitHub issue:
Closing this now, as these projects load with 15.3. The current way to use them:
Download VS 2017 Update 3 Preview 3 (or a further preview if it's released and you're reading this)
Download the latest CLI/SDK from here: https://github.com/dotnet/cli/tree/release/2.0.0#installers-and-binaries
(Yes, the .NET SDK is independent of VS. You will also need this to get .NET Core 2.0 support in VS 2017 Update 3 Previews).

TFS 2010 issues building C#6.0 code with MS Build 14

We have TFS 2010 running happily on a dedicated build server.
I have installed Microsoft Build Tools 2015, which includes MS Build 14 successfully on the build machine, but not Visual Studio 2015.
I've created a custom template which alters the "ToolsPath" property of the "Run MSBuild" activity to "C:\Program Files (x86)\MSBuild\14.0\Bin".
The build runs, but fails on this particular error:
(CoreCompile target) ->
CSC : error CS1566: Error reading resource 'ProjectName.exe.licenses' --
'Could not find file 'C:\develop\Sources\ProjectName\obj\x86\Release\ProjectName.exe.licenses'.' [C:\develop\Sources\ProjectName\ProjectName.csproj]
The same project builds fine using Visual Studio 2015 running from another machine.
It makes no difference whether the TFS build definition includes these MS Build arguments or not:
/tv:14.0 /p:VisualStudioVersion=14.0
Does anybody have a success story of using a TFS 2010 build agent to successfully build a C#6.0 project?
I solved this in the end by installing Visual Studio 2015!
The /tv:14.0 /p:VisualStudioVersion=14.0 argument may don't work for MSBuild Tools.
You should customize the tfs build process template to set ToolPath of the Run MSBuild for Project to target to MSBuild14; and set ToolVersion to "14.0".
Check this link for the detailed information:BuildActivity ignores ToolsVersion

Unable to build WiX 3.10 project in TFS 2015

I am using TFS 2015 trail version in windows server 2012.I created windows service project in visual studio community edition along with WiX Project to package the windows service. If i build the solution from visual studio, I am able to get the MSI. But if i use Visual studio build in TFS 2015,i get the following error.
"Unexpected exit code received from msbuild.exe: 1" and "Task VSBuild
failed. This caused the job to fail. Look at the logs for the task for
more details."
I refered the below links as reference :
http://wixtoolset.org/documentation/manual/v3/msbuild/wix_with_team_build.html-
http://wixtoolset.org/documentation/manual/v3/msbuild/daily_builds.html
1) I am unable to follow the first link steps as i got struck in step 2:
i am unable to find configuration folder in build definition.
I was reading that we do not have TFSBuild.proj straing from TFS version 2010.
"Right-click on the Build Definition and select View Configuration
Folder." "Check out and open the file named TFSBuild.proj."
2)I am unable to follow second link as well. I am getting below error:
"The imported project "C:\wix\3.8\Wix.targets" was not found. Confirm
that the path in the declaration is correct, and that the
file exists on disk."
since I am new to TFS Build 2015, any help or guidance will be appreciated.
Beginning with NuGet 2.7, the NuGet Visual Studio extension integrates into Visual Studio's build events and restores missing packages when a build begins. This feature is enabled by default. If you are using NuGet to install Wix packages, that's why you can get a successful build from visual studio.
If you want to use NuGet to install Wix packages, you can create one build.proj to restore these packages during build. Check: http://docs.nuget.org/consume/package-restore/team-build
If you don't use NuGet to install Wix packages, a traditional way you can refer to:http://edwinfrey.com/blog/2012/06/11/building-wix-msis-in-tfs-preview/

Web.config fail to transform on TFS 2012

I currently work on a MVC 4.0 project that was upgraded to MVC 5.0 using the official guide.
I use Visual Studio 2012 locally and a publish profile was created for the project.
Locally I call msbuild via the Visual Studio developer command prompt using: msbuild /m /p:Configuration=Dev;DeployOnBuild=true;PublishProfile=Dev my-solution.sln
All projects in the solutions do have a Dev configuration and there is a web.dev.config.
The command line on the server is the same.
So far the difference is that on the server only the visual studio shell is installed (not the full) and we cannot install the full instance of VS2012 on the server.
Also, seeing on the install of TFS on the server, I discovered that only v9.0 target files were installed (Visual Studio 2008). Copying Visual Studio 2012 target files do not fix this problem.
I see 2 solutions so far but searching for a third.
Install full Visual Studio 2012 instance
Update csproj to include a target transformConfigFiles (basically copy and paste the content of the "Microsoft.Web.Publishing.targets" section) or import the file via a declaration inside of the .csproj
Would there be a third solution available?
It is pretty common to install full Visual Studio on your build server. As of VS 2012 you couldn't even run Unit Tests in your build without VS installed.
I'd suggest installing VS and seeing if that fixes the issue.

Resources