FxCop - How to resolve Windows, Version 255.255.255.255? - continuous-integration

I am trying to get FxCop 10 to run analysis on a Windows 8 build computer and seem to have run up against a wall.
When I run it with /verbose against a dll, I get:
Could not resolve reference to Windows. Could not load [path to my dll]. The following error was encountered while reading module [name of my module]: Assembly reference cannot be resolved: Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null
I have it pointing to the VS 2012 minimum recommended rules and can get it to run code analysis from visual studio if I set the FxCopCmd.exe.config:
Here is my command line version, which produces the error mentioned above:
fxcopcmd /file:"D:\Source\Project\bin\release\myproject.dll" /out:"D:\temp\fxcop-report.xml" /rs:="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset" /s /assemblyCompareMode:StrongNameIgnoringVersion /searchgac /verbose
I get prompted for Windows, Version 255.255.255.255 if I try to run analysis using the FxCop application as well.
This is a Windows 8 Phone project.

Try adding this switch to your FxCopCmd command:
/directory:"C:\Program Files (x86)\Windows Phone Kits\8.0\Windows MetaData"
That worked for me when I met the same error running Visual Studio Code Metrics Powertool for Visual Studio 2013 (metrics.exe).

Related

What runtime dependencies does TLBIMP have?

Setting up a clean build machine I have only installed VS2019 so far, including Windows 10 SDK, as far as 3rd-party software is concerned.
An ODL file has custom compile step:
midl /out ..\dll %(FullPath)
TLBIMP ../dll/%(Filename).tlb /namespace:MyOrg.COM /keyfile:../include/MyOrg.snk /out:../dll/%(Filename).dll
This gives the build error:
1>'TLBIMP' is not recognized as an internal or external command,
1>operable program or batch file. 1>C:\Program Files (x86)\Microsoft
Visual
Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(231,5):
error MSB6006: "cmd.exe" exited with code 9009.
Clearly MIDL is working, what additional Visual Studio/Windows components do I need to install for TMPLIB?
As Simon points out in comments, TLMIMP.exe is a standard VS tool. Depending which Windows SDK is being used it should be found in:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbImp.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools
You might have multiple versions installed, which is used during a build will depend on your %PATH variable. This would normally be set whenever you run Visual Studio Developer Command Prompt (I assume if you build within the IDE it's done automatically).
My issue was actually that I'm building with Azure Devops and it doesn't automatically add this folder to the build path.

MSBuild offline installer that comes with visual studio 2017 build tools not able to build project in Release mode

Step 1 - I have installed visual studio build tools by downloading
vs_BuildTools.exe from this site (you will require to login to microsoft account to browse this URL)
Step 2 - I created offline installer by following various articles particularly this one
And created zip file offlineBuildTools17.zip
Step 3 - Copied offlineBuildTools17.zip file to Build server which doesn't have internet connection.
Build server is Windows server 2012 R2.
Step 4 - Extracted Zip file on server and installed Build tools. Installation goes smoothly.
I could see installation files in
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft
Step 5 - I have simple DLL and Console application (.exe) project in my solution. These are simply 'hello world' application NOT USING DOT NET CORE. I am using .net frameowrk 4
Problem: I am unable to create release mode dlls and exe
Same thing is working on my laptop where I have installed visual studio 2017 community edition.
On laptop where visual studio 2017 installed
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild" <optional project.csproj> /p:Configuration=Release
This creates dlls and exe in bin\Release folder of project
But the same doesn't work on Build server.
Always creates dlls and exe in bin\debug folder.
My final goal is to create 'publish' folder
This is weird but it is solving my problem.
if i ran following command - msbuild is always generating Debug binaries. which was my original problem. it doesn't generate release mode binaries at all
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\"msbuild /p:Configuration=Release /t:publish /p:OutDir="./Publish"
But if i write following command , (note how msbuild is placed in double quote along with mbuild full path) it is working fine. it generates release mode binaries and also publish folders.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild" /p:Configuration=Release /t:publish /p:OutDir="./Publish"
thanks

PVS Studio not working with MSVS not installed in default location

Due to disk size constraints, I installed MSVS 2017 to D:\Program Files\Visual Studio.
I then installed PVS-Studio v6.14. When I tried to run it, I get the following error messages:
Error was encountered while opening project 'MIDI2LR.vcxproj'. 0
Exception message: 0
Could not find a part of the path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC'. 0
It also appears that PVS-Studio did install its extensions into the D:\Program Files\Visual Studio\Common7\IDE\Extensions\3ci0fu2p.p0x directory, so it appears that the installer found the executable.
How do I point PVS-Studio to the correct directories?
If I have understood correctly, we are talking about /Builds/VisualStudio2017/MIDI2LR.vcxproj from your repository (develop branch). If you're talking about another project, please specify it. The information is based on the analysis of the project I mentioned before.
Does this project compile on your machine? If a project does not compile, PVS-Studio does not guarantee the analysis. Otherwise, the analysis should be performed correctly. I also note that for the compilation you have to have the components Visual C++ Build Tools 2015 installed (in this context we use the contents of the directory C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC).
In this case, such behavior occurs because of your project's file structure – the PlatformToolset property is set with a value v140 before the import of Microsoft.Cpp.Default.props, thus this import is performed based on this toolset. This causes MSBuild to use the compiler from Visual C++ 2015, and not from Visual C++ 2017.
To compile using the compiler from VS2017 (V141 toolset), you need to modify the project file (see example of a console application project file that is created in Visual Studio 2017). Then the compilation should be done with a correct compiler and the analysis with PVS-Studio performed correctly.

Visual Studio Empty Cordova Multi Device Hybrid App Build Failure [error code 8]

Having tried to follow all advices, remedies and workarounds including removing and reinstalling the Multi-Device Hybrid Apps for Visual Studio CPT1 I still can't seem to do a successful build of the included "Blank App (Apache Cordova)" project.
Build ends consistently in one single error:
The command ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7
\IDE\Extensions\k04kuuo3.ie0\packages\vs-mda\install" "C:\Program Files (x86)
\nodejs\" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7
\IDE\Extensions\k04kuuo3.ie0\packages\vs-mda"" exited with code 8.
File %USERPROFILE%\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets
Line 108
Column 5
Project BlankCordovaApp1
Environment settings:
ADT_HOME %USERPROFILE%\AppData\Local\Android\android-sdk
ANT_HOME C:\apache-ant-1.9.3
GIT_HOME C:\Program Files (x86)\Git\cmd
JAVA_HOME C:\Program Files (x86)\Java\jdk1.7.0_55
PATH %JAVA_HOME%\bin;%ANT_HOME%\bin;%ADT_HOME%\platform-tools;%ADT_HOME%\tools;
C:\Program Files (x86)\nodejs\;C:\Program Files (x86)\Windows Kits\8.1\Windows
Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\
(contains no reference to "Platform")
Your kind help is very much appreciated, Thanks Ian
I just ran into this on one of my PCs and here's how I got it fixed:
Quit Visual Studio
Open the Android SDK manager by typing the Windows key and then "SDK manager", hit enter
Install Android Build Tools Rev 19 by checking the box next to it and clicking Install packages
Accept the license
Open Visual Studio and your project, then run it again
Jordan (Microsoft, Multi-Device Hybrid Apps tools team)
Finally the light bulb went on for me: The problem was the install batch files not being able to locate xcopy.exe and therefore the simple remedy was to just extend the path variable with
%SystemRoot%\system32;
The build now runs without further errors.
Thanks Jordan and Ian.
I ended up doing both.
I ran the Android SDK manager to install the Android Build Tools Rev 19 as well as some other updates.
I also added "%SystemRoot%\system32;" to the PATH environment variable.
Everything running as it should.

VS 2013 and MSBuild

I've recently upgraded to Visual Studio 2013, which has caused back to back problems when building externally using MSBuild (API or Executable with command line args)
Issue #1
When building with MSBuild it doesn't generate Fake assemblies which are required for our Unit Tests, this leads to build failures. A simple build in visual studio fixes this temporarily, until a new fake assembly needs to be generated.
Issue #2
When running code analysis this complains with the following:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(284,5):
error MSB4127: The "CodeAnalysis" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\.\FxCopTask.dll".
Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.CodeAnalysis' to type 'Microsoft.Build.Framework.ITask'.
I only have Visual Studio 2013 installed on my machine, apparently installing an older version could fix the issue, but it's not something which I can do. (VS 2013 Ships with its own MSBuild 12.0 which is located in a different directory to the previous MSBuild).
I'm unsure why Visual Studio is behaving any differently to MSBuild, i'm simply pointing to the solution file like so...
msbuild.exe "path\solution.sln" /property:Configuration=Debug
So, Visual Studio 2013 comes with a new version of MSBuild i.e. MSBuild 12.0. Once installed, it changes the path so that the new version is used by default.
Looks like your solution compiles with visual studio 2012, you can either specify the full path to msbuild.exe such as
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "path\solution.sln" /property:Configuration=Debug
or set the visual studio 2012 environment variables by running the following before executing msbuild
"%VS110COMNTOOLS%"\vsvars32.bat // VS2012 environment variables
EDIT: Using MSbuild 12.0 assemblies "C:\Program Files (x86)\MSBuild\12.0\Bin\" fixes the issue with the code Analysis bug.

Resources