MSBuild is being run from within the "Visual Studio Command Prompt" - c#

I am using VS2017 Enterprise for first the time building my repository. Have cloned code from my VS repository and trying to build it but build failed.
And also i have set environment variable path -->
PATH : C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
Error message :
Severity Code Description Project File Line Suppression State Error
MSBuild could not locate the Code Analysis tool at
'Drive:\Repo\NugetPackages\CarbonV2.FxCop.SDL.14.0.23107.0\Tools\FxCopCmd.exe'.
If MSBuild is being run from within the "Visual Studio Command
Prompt", specify the path to the Code Analysis tool by setting the
FXCOPDIR environment variable. Demo.Service.Common
Could you please help on this, did i missed any thing?

What's standing out to me is that i'm seeing NugetPackages - leading me to believe you're missing something from Nuget.
https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore#restore-packages-automatically-using-visual-studio
You can install the FXCOP manually, or follow the instructions in that article to have NuGet attempt to get all of the missing packages automatically for you. Hope this helps!

Related

Docfx saying succeeded but no output files are generated

When attempting to use Docfx to document a C# project I am running into an issue that is probably down to myself being a moron. However I have read through the docfx examples and I have not seen any obvious ways of rectifying the issue.
When I run docfx init -q I get no errors. When I run docfx docfx.json --serve I also get no errors, upon completed I get a Build succeeded. 0 Warnings 0 Errors message however no html files are generated.
It also appears to be correctly reading the source files from my project as the api folder has yml files with the same names as the class files in the project.
How do I get docfx to generated the appropriate html files for the project. Full output of docfx docfx.json --serve is below:
[19-07-04 05:07:47.020]Info:[MetadataCommand.ExtractMetadata]Using msbuild C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin as inner compiler.
[19-07-04 05:07:47.302]Info:[MetadataCommand.ExtractMetadata]Loading projects...
[19-07-04 05:07:50.379]Info:[MetadataCommand.ExtractMetadata]'C:/Users/Devvy/Source/Repos/TestProj/TestProj.csproj,C:/Users/Devvy/Source/Repos/TestProj/Display_Output.cs,C:/Users/Devvy/Source/Repos/TestProjException.cs,C:/Users/Devvy/Source/Repos/TestProj_Core.cs,C:/Users/Devvy/Source/Repos/TestProj/Module_Info.cs,C:/Users/Devvy/Source/Repos/TestProj/Opcode_Assembler.cs,C:/Users/Devvy/Source/Repos/TestProj/Opcode_Disassembler.cs,C:/Users/Devvy/Source/Repos/TestProj/Pattern_Tools.cs,C:/Users/Devvy/Source/Repos/TestProj/Payloads.cs,C:/Users/Devvy/Source/Repos/TestProj/Process_Info.cs,C:/Users/Devvy/Source/Repos/TestProj/PtrRemover.cs,C:/Users/Devvy/Source/Repos/TestProj/RopChainGenerator32.cs,C:/Users/Devvy/Source/Repos/TestProj/RopChainGenerator64.cs,C:/Users/Devvy/Source/Repos/TestProj/Thread_Info.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Debug/net472.AssemblyInfo.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Debug/net472/TestProj.AssemblyInfo.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Debug/net472_Lib.AssemblyInfo.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Debug/net472/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Debug/net472/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Debug/net472/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Debug/netstandard2.0.AssemblyInfo.cs,C:/Users/Devvy/Source/Repos/TestProj/obj/Release/net472/TestProj.AssemblyInfo.cs' keep up-to-date since '7/4/2019 5:03:14 PM', cached result from 'C:/Users/Devvy/Source/Repos/TestProj/Documentation/api' is used.
[19-07-04 05:07:50.379]Info:[MetadataCommand]Completed Scope:MetadataCommand in 3384.2278 milliseconds.
[19-07-04 05:07:50.379]Info:Completed in 3389.2213 milliseconds
Build succeeded.
0 Warning(s)
0 Error(s)
Docfx provides static code documentation for us. If you want to static website of output with docfx correctly. You should follow these steps;
First you must install docfx. You have many way but I recommend install with choco
choco install docfx -y
then you must add your project docfx console package from NuGet
Install-Package docfx.console -Version 2.33.0
now open your project folder or whatever you want create a folder then run like that
docfx init
now best part of this answer you must config you'r project docfx.json file like this
after run
docfx --serve
Also I found a example project here
I think your problem about you're docfx file configuration.

TeamCity with SonarQube for Code Analysis build fails

Very common problem for many users, that SonarQube Code Analysis fails with an error:
[10:06:05]No ProjectInfo.xml files were found. Possible causes:
[10:06:05]1. The project has not been built - the end step was called right
after the begin step, without a build step in between
[10:06:05]2. An unsupported version of MSBuild has been used to build the
project. Currently MSBuild 12.0 upwards are supported
[10:06:05]3. The build step has been launched from a different working folder
[10:06:05]Post-processing failed. Exit code: 1
[10:06:05]Process exited with code 1
A lot of references say that fix is to use full path for MSBuild.exe, but yes, I use full path, but also I use MSBuild 15.0 version with newest C# version, older MSBuild just fails for new C# features in code.
However I can't get rid of this error and I have no idea what can be done about it, so maybe any of you guys have already met this problem and could help me?
EDITED
I am pretty sure that none of these steps should be the reason for the fail, the second one only the closest one, because my build steps are
Team City build steps look like the following.
Step XX:
cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" begin ... params
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" "MyProject.sln" /t:Clean;Rebuild
Step XY:
...
Step XZ: (the last)
cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" end
For me it looks very simple and easy to understand, but still I got that error and I have no idea why, the error is thrown in the last step (XZ).
You need to upgrade to a newer version of the Scanner for MSBuild. I'd suggest upgrading to the newest available version (v4.2 at the time of writing).
The scanner copies a targets file under the following location for each supported version of MBuild: %localappdata%\Microsoft\MSBuild[MSBuild version]\Microsoft.Common.targets\ImportBefore.
From the look of the log output you are using an version of the Scanner for MSBuild that pre-dates the release of MSBuild 15, so the file won't be copied to the MSBuild15-specific location. This will lead to the "no ProjectInfo.xml files were found" state.
It would be better if the warning message in the scanner log explicitly listed the range of MSBuild versions that were supported e.g. "This version of the Scanner supports MSBuild v12.0 to v14.0". I've created issue #502 to track this.

MSBuild successful but Visual Studio failed

We're using Jenkins to build out projects using msbuild.
I added a project reference to an existing project but forgot to add these new project to all solution files.
I committed but Jenkins told me that everything works fine.
I tried that on command line:
msbuild test.sln /t:Rebuild /p:Configuration=Debug
Having a totally cleared working directory that works fine, in Jenkins and on my developing machine. The output told me that msbuild found that project and build it.
But if I open Visual Studio 2017 and try to build that solution, it tells me that the depending project could not be found.
That's correct.
How do I force msbuild to only build projects that are specified in the solution file so that we're able to find all solutions that missed that new project?
BTW: We don't need a hint how to find all solutions that need to contain that new project. Finding that solutions is pretty easy.
How do I force msbuild to only build projects that are specified in the solution file so that we're able to find all solutions that missed that new project?
The correct way to avoid MSBuild's default behavior of rebuilding all the dependencies listed in the solution file is to set the BuildProjectReferences property to false, So the build command line should be:
MSBuild Test.sln /t:Rebuild /p:Configuration=Debug /p:BuildProjectReferences=false
After using this command line, MSBuild will get the same error with VS, so we're able to find all solutions that missed that new project
Note: BuildProjectReferences will check all the dependencies listed in the solution file, so please keep his value is true, unless used to check the missing dependencies.
Hope this helps.

The Command...Exited With Code -532462766

This is the line that gives me the error.
<Exec Command=""$(MonoGameContentBuilderExe)"
/#:"%(ContentReferences.FullPath)" $(Header)"
WorkingDirectory="%(ContentReferences.RootDir)%(ContentReferences.Directory)" />
It is from the MonoGame.Content.Builder.targets file.
The full error is:
The command ""C:\Program Files
(x86)\MSBuild\MonoGame\v3.0\Tools\MGCB.exe"
/#:"C:\Users\Jake\documents\visual studio
2015\Projects\FirstGame\FirstGame\Content\Content.mgcb"
/platform:Windows /outputDir:"C:\Users\Jake\documents\visual studio
2015\Projects\FirstGame\FirstGame\Content\bin\Windows"
/intermediateDir:"C:\Users\Jake\documents\visual studio
2015\Projects\FirstGame\FirstGame\Content\obj\Windows" /quiet" exited
with code -532462766.
I have been converting this game from Visual Studio 2010 to Visual Studio 2015, which is when this error started. Does anyone have any insight into what may be causing this?
It turned out that I was attempting to load in an image file made in gimp which has an unsupported file type. I just needed to export it as a png and it worked fine.
In my case, the same error code was being thrown by the roslyn compiler when trying to compile cshtml files.
Turns out that the issue was being caused due to roslyn compiler version mismatch. Let me try and explain the problem:
My csproj had nuget references to roslyn compiler assemblies (Microsoft.Net.Compilers and Microsoft.CodeDom.Providers.DotNetCompilerPlatform).
I use git for source control
I had recently updated to the latest version of roslyn compiler on DEV branch
But my MASTER branch was still referencing the previous version of roslyn compiler and I was not yet ready to merge DEV to MASTER
Switching from dev to master branch from team explorer did not seem to trigger "nuget restore" for the mismatched packages
So manually deleting all the folders in the packages folder and performing a "nuget restore" resolved this error for me.

How can I resolve the error: "The command [...] exited with code 1"?

I've read around many questions but I've not been able to find the right answer for me.
As I try to compile a project in VS2012 I have this result:
The command "....\tools\bin\nuget pack Packages\Lib.Html.nuspec - OutputDirectory ....\bin\Zip\Packages -NoPackageAnalysis" exited with code 1.
I looked for the line of code in my .csproj file, where the error should be, and there is:
<Exec Command="$(ProjectDir)..\..\tools\bin\nuget pack $(ProjectDir)Packages\Lib.Html.nuspec -OutputDirectory $(OutputPath)Packages -NoPackageAnalysis" />
What am I doing wrong?
[EDIT]
Launching the Debug of that project and ignoring "building errors", I have a new alert:
"Visual Studio cannot start debugging because the debug target '[project.exe path]' is missing.
Please build the project and retry, or set OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly."
The first step is figuring out what the error actually is. In order to do this expand your MsBuild output to be diagnostic. This will reveal the actual command executed and hopefully the full error message as well
Tools -> Options
Projects and Solutions -> Build and Run
Change "MsBuild project build output verbosity" to "Diagnostic".
Right click project -> Properties -> Build Events
Remove the text in Post-build event command line text block
For me : I have a white space in my path's folder name G:\Other Imp Projects\Mi.....
Solution 1 :
Remove white space from folder
Example: Other Imp Projects ->> Other_Imp_Projects
Solution 2:
add Quote ("") for your path.
Example: mkdir "$(ProjectDir)$(OutDir)Configurations" //see double quotes
Try to open Visual Studio as admin.
For me, in VS 2013, I had to get rid of missing references under References in the UI project (MVC). Turns out, the ones missing were not referenced.
I know this is too late for sure, but, this could help someone as well.
In my case, i found that the source file is being used by another process which was restricting from copying to the destination. I found that by using command prompt ( just copy paste the post build command to the command prompt and executed gave me the error info).
Make sure that you can copy from the command prompt,
This builds on the answer from JaredPar... and is for VS2017. The same "Build and Run" options are present in Visual Studio 2017.
I was getting, The command "chmod +x """ exited with code 1
In the build output window, I searched for "Error" and found a few errors in the same general area. I was able to click on a link in the build output, and found that the error involved this entry in the .targets file:
<Target Name="ChmodChromeDriver" BeforeTargets="BeforeBuild" Condition="'$(WebDriverPlatform)' != 'win32'">
<Exec Command="chmod +x "$(ChromeDriverSrcPath)"" />
</Target>
In the build output, I also found a more detailed error message that essentially stated that it couldn't find Selenium.WebDriver.ChromeDriver v2.36 in the packages folder it was looking in. I checked the project's NuGet packages, and version 2.36 was indeed in the list of installed packages. I did find the package files for 2.36, and changed the attributes on the folder, subfolders and files from "Read Only" to "Read/Write". Built, but same failure. Sometimes "updating" to a different version of the package and then updating back to the original can fix this type of error. So I "updated" the reference in Manage NuGet packages to 2.37, built, failed, then "updated" back to 2.36, built, and the build succeeded without the "chmod +x" error message.
The project I was building was based on a Visual Studio Project template for Appium test tooling, template name "Develop_Automated_Test".
Check your paths:
If you are using a separate build server for TFS (most likely), make sure that all your paths in the .csproj file match the TFS server paths. I got the above error when checking in the *.csproj file when it had references to my development machine paths and not the TFS server paths.
Remove multi-line commands: Also, try and remove multi-line commands into single-line commands in xml as a precaution. I had the following xml in the *.proj that caused issues in TFS:
<Exec Condition="bl.."
Command=" Blah...
..." </Exec>
Changing the above xml to this worked:
<Exec Condition="bl.." Command=" Blah..." </Exec>
I had the same issue. Tried all the above answers. It was actually complained about a .dll file. I clean the project in Visual Studio but the .dll file still remains, so I deleted in manually from the bin folder and it worked.
Hope this helps someone, but I had prebuild events and post build events and it kept complaining about a file called "Microsoft.Common.CurrentVersion.targets" "The target "CoreBuild" does not exist in the project".
Here's what I did to resolve it:
close the project
delete the .suo file (it regenerates)
Asked a team member to provide a copy of that file (Microsoft.Common.CurrentVersion.targets) - mine was different - I took his.
It compiled - good to go.
I must have wrecked that file somehow.
There was no syntax error in my batch file and it ran fine on a cmd prompt outside VS.
So finally, I added
exit 0
to return a success code explicitly at the end of my batch file and it started working.
For me the output file (.dll) of the same version already existed so I guess it was having trouble overwriting. Even though it has never done it before. Anyways, deleting the existing file and running Rebuild fixed it for me.
If the previous method wouldn't have fixed it, my next check would have been to check if the path length was causing it. So would have change the target folder to somewhere close like the Desktop so that the path isnt too long.
Hint: Search for "Exec Command=" in your project
In my case I found following tag in "Microsoft.Extensions.ApiDescription.Server.targets" file, I remarked the line and it worked for me:
<Exec Command="$(_Command)" LogStandardErrorAsError="true" />

Categories

Resources