I have this simple test project in vs 2013 I reference the Microsoft.TeamFoundation.Client in my library so added a Microsoft.Teamfoundation.Client.12.0.0.0.Fakes in the test project, using right click add fakes assembly.
Locally everything works fine but when i run the project trough the build server using the default template I get Fakes: code : assembly XXX\Microsoft.TeamFoundation.Client.dll failed to load properly.
The non fake dll's are included in a solution folder.
Any other assembly added by fakes working perfectly fine but as soon as I fake the Microsoft.Teamfoundation. my build breaks.
Using VS2013 with TFS 2012 update 2.
I had the similar issue. The problem is because TFS and Visual Studio versions are not the same. I installed VS 2013 to the server where TFS Build Server installed.
Then renamed C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Fakes folder and copied
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Fakes folder into C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Fakes. This will solve your problem I guess.
Related
Problem
I just committed the addition of a UWP application to source control. However, my CI server (Jenkins) didn't seem to like that:
error MSB4019: The imported project "C:\Program Files
(x86)\MSBuild\Microsoft\WindowsXaml\v14.0\Microsoft.Windows.UI.Xaml.CSharp.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
This is stemming from the following UWP project file import:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
On my local machine, I can see this file located at:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.Targets
Obviously, this is due to my local installation of Visual Studio 2017. However, the CI server does not have Visual Studio installed. I imagine this is why MSBuildExtensionsPath is resolving to the path mentioned in the error instead.
Dependencies
The following items are already installed on the CI server:
Visual Studio Build Tools 2017 (download)
Windows 10 SDK 10.0.15063.468 (download)
Xamarin.VisualStudio 4.5.0.476 (download)
.NET Framework 4.5.1-4.7 SDKs
I assumed these would include the necessary dependencies, but I cannot find Microsoft.Windows.UI.Xaml.CSharp.targets anywhere.
Workaround
Copying the directory on my local machine
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\WindowsXaml\v15.0
to the CI server at
C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0
seems to resolve the error, but it feels very hacky.
Question
Is there a way to resolve this without installing Visual Studio 2017 on the CI server or copying/renaming files manually?
UPDATE 2018-01-12:
This is still an issue with the latest version of VSBT. The only thing to report is the error changed from v14 to v15. After copying the same directory over to v15, the error is gone again. However, another seemingly unrelated error shows up:
C:\Program Files (x86)\Microsoft Visual
Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1124,5):
error MSB3644: The reference assemblies for framework
".NETCore,Version=v5.0" were not found. To resolve this, install the
SDK or Targeting Pack for this framework version or retarget your
application to a version of the framework for which you have the SDK
or Targeting Pack installed. Note that assemblies will be resolved
from the Global Assembly Cache (GAC) and will be used in place of
reference assemblies. Therefore your assembly may not be correctly
targeted for the framework you intend.
UPDATE 2018-01-15
.NETCore,Version=v5.0 error resolved by copying the following directory from my local machine to the build server:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0
While the UWP build is successful, no appxbundle is generated. This seems to indicate another dependency is missing from VSBT.
When trying to run nunit3-console.exe on my testing dll project on jenkins machine
I'm Getting Invalid : E:\Jenkins\workspace\XXX.Tests.dll
Has no TestFixtures
the dll was created by jenkins using msbuild.exe
on my dev machine machine it works perfectly using the build from Visual studio
Turns out that i had another testing project in the solution with an older version of nunit
and on jenkins it was building the solution and copying the binaries to the same folder
making the nunit.framework.xml to be overwritten
the solution was making sure that both project referenced the latest nunit version.
I'm having an issue on teamcity (9.1.7). I don't have visual studio installed on the build server. I have installed visual studio test agents and msbuild tools. Building one of the project fails with this error-
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppXPackage.Targets(694, 9): error APPX1639: File 'Windows.props' not found. See http://go.microsoft.com/fwlink/?prd=12395&pver=1.0&plcid=0x409&ar=MSDN&sar=PlatformMultiTargeting&o1=Portable&o2=7.0 for more information
The link doesn't work. After looking up the error, it seems i need to install Windows Kits and I need to add this to my csproj file under the first property group -
<_WindowsKitBinPath>C:\Program Files (x86)\Windows Kits\8.1\bin\x86</_WindowsKitBinPath>
<_WindowsPhoneKitBinPath>C:\Program Files (x86)\Windows Phone Kits\8.1\bin</_WindowsPhoneKitBinPath>
<MakePriExeFullPath>$(_WindowsKitBinPath)\makepri.exe</MakePriExeFullPath>
<MakeAppxExeFullPath>$(_WindowsKitBinPath)\makeappx.exe</MakeAppxExeFullPath>
<SignAppxPackageExeFullPath>$(_WindowsKitBinPath)\signtool.exe</SignAppxPackageExeFullPath>
<MakePriExtensionPath>$(_WindowsPhoneKitBinPath)\x86\MrmEnvironmentExtDl.dll</MakePriExtensionPath>
<MakePriExtensionPath_x64>$(_WindowsPhoneKitBinPath)\x64\MrmEnvironmentExtDl.dll</MakePriExtensionPath_x64>
I really don't want to add this to my csproj file. I don't know why it is required/what impact it has. Can someone explain to me why this is needed? When i build my solution locally with visual studio, it works fine.
The groups of settings are basically bootstrapping parameters that are required by MSBuild in order to compile the project (A native windows phone app??). You've probably got the kit installed locally and something already integrated into Visual Studio, which is why it builds. Uninstall the Visual Studio add-in and it'll probably start failing.
You can setup your compile step to pass in these parameters without requiring them in the .csproj file if you don't want them there.
I normally abstract additional build parameters to a variable in TeamCity
Hope this helps
I am getting this error on my CI server:
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" was not found
It seems my WCF service library project references that file, but the VisualStudio folder on Program Files\MSBuild\Microsoft doesn't contain a WCF folder.
I guess I need to install something on the server.
What do I need to install?
Well this ruined my morning, but let's not allow it to ruin anyone else's. I couldn't find this information anywhere else. You need to copy a few files from a development machine with VS Pro 2012.
As aphexddb mentions, you need to copy some targets from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF to the same location on your CI server.
This then references an assembly called Microsoft.VisualStudio.ServiceModel.Core. You can find this assembly in either the GAC or in the IDE directory at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE.
Copy this to your CI server and execute gacutil.exe -i Microsoft.VisualStudio.ServiceModel.Core.dll
This was enough to fix it for me.
This isn't the first time I found targets missing from my VS express install in my CI server. I can't help but feel that there is some sort of package I can download from somewhere that fills all this in. Does anyone know of such a thing? If not, perhaps we should create one.
Can still happen on vs2019
error MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\WCF\Microsoft.VisualStudio.ServiceModel.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
WCF is not installed by default as part of 'ASP.NET and web development' workload. To fix this,
On visual studio installer > modify > individual components tab, search for wcf, check, modify - the .targets file gets now installed, msbuild builds ok.
MSBuild auto-detection: using msbuild version '16.3.2.50909' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin'
I ran into this with Visual Studio 2017, for me the resolution was to modify my installation of Visual Studio to include the Windows Communication Foundation components.
Extract this file into folder
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF
The file name is "Microsoft.VisualStudio.ServiceModel.targets"
Now you can solve the problem using the Nuget Package MSBuild.Microsoft.VisualStudio.Web.targets
so the build process does not require any change to the build server.
Install-Package MSBuild.Microsoft.VisualStudio.Web.targets
Details:
remove the element for "ServiceModels.targets" in the .csproj file
remove the target WebApplication from the build command (in yaml)
Ran into this same issue. Did the following to resolve:
Installed the Microsoft Web Platform Installer
Copied Directory "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF" from dev laptop with Visual Studio 2012 to the build server
I've had the same error - my issue was that MS has modified the way MSBuild looks for the versions of VS in the build process template.
Make sure to use the right build process template.
If using TFS2013 and VS2013 use TfvcTemplate.12.xaml
I ran into this same error. In my case, the problem was that my Visual Studio 2008 project didn't get upgraded correctly, probably due to files being marked "read-only" by my source control. To fix it, I loaded the solution in Visual Studio 2015 with everything checked out.
The specific line in the .csproj file changed from
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" />
To
<Import Project="$(WcfServiceModelTargetPath)\Microsoft.VisualStudio.ServiceModel.targets" />
If you are using VS 2022 build tools, it is no longer in the individual components section. It is on the first tab "Workloads", included in ".NET desktop build tools", you will see it in the list on the right-hand side when you select it.
On a Windows Server 2003 R2 with .NET 4 SDK but without Visual Studio 2010, I have tried building a Visual Studio 2010 solution with
msbuild MySolution.sln /p:RunCodeAnalysis=true
but that fails.
What is required to run code analysis on such an environment?
I get this error message:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB6003:
The specified task executable "FxCopCmd.exe" could not be run.
Could not load file or assembly
'Microsoft.VisualStudio.CodeAnalysis.Sdk, Version=10.0.0.0, Culture=neutral, PublicKeyToken= b03f5f7f11d50a3a'
or one of its dependencies.
The system cannot find the file specified.
I have installed FxCop from the SDK and without luck pointed the variable FxCopDir to the installed location of FxCopCmd.exe, and also setting this registry entry to that location:
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev#FxCopDir
I had the same problem on my MSBuild server and fixed it by:
Installing Windows SDK 7.1
Setting up the registry keys FxCopDir and StanDir in HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev (in Win32).
I then copied over from the dev PC, to the FxCop folder on the build server, the following:
The folder Rule Sets (default installation target is here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop)
Microsoft.VisualStudio.CodeAnalysis.Sdk.dll
Microsoft.VisualStudio.CodeAnalysis.Phoenix.dll
phx.dll
Do a search for them on your dev PC with Visual Studio installed to locate them.
Then use the .NET 4.0 version of gacutil.exe to install Microsoft.VisualStudio.CodeAnalysis.Sdk.dll to the GAC.
You should then be able to run code analysis as part of an MSBuild build and have it work properly.
An alternative to FxCop would be to use the tool NDepend that lets write Code Rules over C# LINQ Queries (namely CQLinq). Disclaimer: I am one of the developers of the tool
More than 200 code rules are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.
Rules can be verified live in Visual Studio and at Build Process time, in a generated HTML+javascript report.
Another option might be calling FxCop executable as a build task (from msbuildtasks), saving the result as an XML file that can be parsed within most of the CI tools (like Hudson and CC.NET)