Does anyone know where I can take a look at my project if after I make a build with MSBuild through MSBuild console I get this warning:
MSB4078: The project file 'MyProject.csproj' is not supported by
MSBuild and cannot be built?
My project is running with Target Framework .Net Core 2.0. The MSBuild version I am using is 14.0.25420.1
This is the cs.proj
You are using the new csproj file format (see Project sdk=...)
You will need to use MSBuild 15 in order for it to build. You have two options:
1) Download Build Tools for Visual Studio 2017 and install. Then the path will be:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
2) If you have VS installed, the path will be:
C:\Program Files (x86)\Microsoft Visual Studio\2017\<VS Version>\MSBuild\15.0\Bin
Using MSBuild 15 should fix the error.
Please check what version of MSBuild are you running. I tested with the version 15.0, it runs without any error.
Generally, make sure that you have configured a build agent for your team project, and that you have Visual Studio 2017 installed on the agent machine and that you installed the latest Visual Studio update.
Also make sure you have select the MSbuild version 15.0 for the build.
See Build your ASP.NET Core app for details.
Reference this related thread: Support for .NET Core .csproj files
I suggest to use MSBuild in more reliable way.
Download Build Tools for Visual Studio 2017 from Visual Studio Downloads page, it includes latest MSBuild 15.* (direct link).
Command-line arguments documented here: Use command-line parameters to install
Visual Studio 2017.
All workloads and components are listed here: Visual Studio Build Tools 2017 component directory.
Use PowerShell module VSSetup to find MSBuild. Download it or install from here: Github: Microsoft/Visual Studio Setup PowerShell Module
Find MS Build
Import-Module $PSScriptRoot\VSSetup\VSSetup.psd1
$msBuildPath = (Get-VSSetupInstance | Select-VSSetupInstance -Version 15.0 -Product Microsoft.VisualStudio.Product.BuildTools).InstallationPath
if ([System.IntPtr]::Size -eq 8)
{
$global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin\amd64'
}
else
{
$global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin'
}
Write-Output "Using MSBuild from $global:msbuildPath"
Write-Output "MSBuild /version"
$msbuild = Join-Path $global:msbuildPath msbuild
& $msbuild /version
Related
MSBuild x64bit in Visual Studio 2019 works alright.
As executing MSBuild in Visual Studio, MSBuild locates:
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\MSBuild\Current\bin\msbuild.exe
However, when running TFS Build, there is an error about "AxImp.exe" missing.
I am sure that I have Windows STKs installed when I installed Visual Studio.
Here is a snapshot of my .csproj property:
Project="$(MSBuildExtensionPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
The TFS build agent resides on the same host having that same Visual Studio.
Here are the build definitions which are defined on TFS server:
MSBuild Version: Latest (or MSBuild 15.0 MSBuild 14.0 or MSBuild 12.0
or MSBuild 4.0)
MSBuild Architecture: MSBuild x64
When building the solution through TFS build, there is an error:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(2015,5):
Error MSB3091: Task failed becaused "AxImp.exe" was not found, or the
correct Mcrosoft Windows SDK is not installed. The task is looking
for "AxImp.exe" in the bin subdirectory beneath the loaction specified
in the InstallationFolder value of the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86.
The log in TFS build shows that msbuild execution is located from:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
I am running the SonarQube 7.5 with Sonar Scanner MsBuild 4.5 and it works but no results is available on the project configured on the Sonar. Let me detail what I have done.
What I have done
I installed the SonarQube V7.5 Community and start it as a Windows Service. I download the MsBuild Scanner 4.5 and add this folder on the PATH of the Windows fallowing the documentation. After that, I create a new project and run the scripts on a Dummy Console Application. The scripts I have run over the console are:
Run the BEGIN step of the SonarQube
SonarScanner.MSBuild.exe begin
/k:"HappyAppKey"
/d:sonar.host.url="http://localhost:9000"
/d:sonar.login="f3965814e7fdcf4f32e26adc1e69d6f5f851cafc"
Run the MSBUILD to compile the project from the sln file
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe HappyApp.sln /t:Rebuild
Run the END step of the SonarQube to analysis and submit
SonarScanner.MSBuild.exe end
/d:sonar.login="f3965814e7fdcf4f32e26adc1e69d6f5f851cafc"
It works without errors and I can see the source code on the sonarQube but no bugs, smell code, duplications etc... are available to see on the SonarQube like the picture bellow
Analysing the generated log on the end step, I can see this warning message
15:24:48.807 WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.
15:24:48.808 WARN: No Roslyn issues report found for this project.
What am I doing wrong? Should I add something on the folder of the project? Any file to configure something? (It's my first time with SonarQube).
Thank you.
Solution: Install the right MsBuild version (which should be 14 or above for .Net Framework projects). Follow these steps:
Download and install the Build Tools for Visual Studio 2017 available on this link
Note that you now have the folder C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin.
Over the command prompt, navigate at the folder and perform a MsBuild -version and you should see the right version:
Microsoft(R) Build Engine versão 15.9.21+g9802d43bc3 para .NET Framework
Copyright (C) Microsoft Corporation. Todos os direitos reservados.
15.9.21.664
If you want, add the folder on the PATH of the Windows.
Build your project using this Msbuild.exe.
SonarScanner.MSBuild.exe begin /k:"MyProjectKey" /d:sonar.verbose=true /d:sonar.host.url="http://localhost:9000" /d:sonar.login="3c8d70d998f72178c7a21c1a83590d8af1f6e014"
MSBuild.exe "D:\temp\MyProject\Project.csproj" /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login="3c8d70d998f72178c7a21c1a83590d8af1f6e014"
Access the the SonarQube from http://localhost:9000 and you should see the result of the analysis.
I have the same issue. But I use the right version of MSBuild.
d:\build\workspace\walls_Build_wb11452\WBServices>d:\build\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Scanner_for_MsBuild_4.6.2\SonarScanner.MSBuild.exe begin /k:project_name /n:project_name /v:"2" /d:sonar.language=cs /d:sonar.sourceEncoding=UTF-8 /d:sonar.host.url="url" /d:sonar.login="******"
SonarScanner for MSBuild 4.6.2
d:\build\workspace\walls_Build_wb11452\WBServices>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" Solution.sln /t:Rebuild /m:2 /p:Configuration=Debug /p:DefineConstants="X64PROCESS;AUTO"
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
No idea...
In .NET core project, I changed the all projects name than after reloading all project that time many errors were showing approx 3225. And mainly all errors are related to system namespace like
System.Object not defined or imported
System.Boolean not defined or imported
Task does not exist
namespace ArgumentNullException could not be found
How do I resolve all those errors?
close VS
delete the bin, obj and .vs (may be hidden) folders
manually run dotnet restore
reopen the project in VS
That fixes most things.
I was hitting this in VS Code. In Windows Terminal, dotnet build and dotnet run ran fine, but I was getting the errors in VS Code. The delete/restore/reopen answer did not fix it.
It seems it was an issue where I had an outdated version of Visual Studio confusing the C#/OmniSharp extension in VS Code.
The OmniSharp log included something like this:
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Enterprise 2019 16.8.30907.101 16.8.3 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
2: StandAlone 17.0.0 - "c:\Users\foo\.vscode-insiders\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Enterprise 2019 16.8.30907.101 16.8.3 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
That version of Visual Studio 2019 did not have the .NET 6.0 SDK installed, and I couldn't find it in the VS Installer.
So I installed Visual Studio 2022 and the .NET 6.0 SDK as part of that install. Now my log looks like this:
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 3 MSBuild instance(s)
1: Visual Studio Enterprise 2022 17.0.31912.275 17.0.0 - "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin"
2: Visual Studio Enterprise 2019 16.8.30907.101 16.8.3 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
3: StandAlone 17.0.0 - "c:\Users\foo\.vscode-insiders\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Enterprise 2022 17.0.31912.275 17.0.0 - "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin"
And the errors are gone!
Disclaimer: I work for Microsoft.
In my case, Error List window had hundreds of errors. But when rebuild the solution, used to get the message Rebuild All Succeeded. And even the project was able to run. But entire code was in red.
Just closing Visual Studio and deleting vs folder did the job.
Gazi's solution above solved my problem which was exactly what she/he described. I had tried updating VS, cleaning and rebuilding solution, restarting VS. Nothing helped. Removing the hidden vs folder at the solution level did the trick. Hope it helps someone!
This can also be caused by a circular dependency between projects in a solution.
error MSB4006: There is a circular dependency in the target dependency graph involving target "_GenerateRestoreProjectPathWalk"
Just like citelao I've got this issue in VS code when created new .NET 6.0 isolated AZ Function using wizard.
In OmniSharp logs I had about the same.
Just in case, in order to see the omni sharp logs, you have to open 'output' panel, and there on the right click on a drop-down:
I did not want to install VS 2022 as my target was to work in VS code for this project. I found the answer here: omnisharp-roslyn #2247
Basically the solution was to add omnisharp.json file in the project root with the following contents:
{
"msbuild": {
"useBundledOnly": true
}
}
After that I've closed VS Code, deleted bin and obj folders and started VS Code back.
I have a .NET Console app with a setup project I am trying to port to VSTS Online (visualstudio.com) to make use of the source control and well as adding automated build/deploy.
I've got the code uploaded just fine and it builds great, but am struggling with getting it to produce a MSI. I've tried introducing a command line task after the solution build to run devenv.com but I can't quite get that to work. Any thoughts on getting a setup project to build its MSI?
Thanks!
EDIT:
Here's the command line task I tried:
Tool: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv
Arguments: SolutionName.sln /Build $(BuildConfiguration) /Project Setup\Setup.vdproj
EDIT 2:
New command line:
Tool: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com
Arguments: MySolution.sln /Build $(BuildConfiguration) /Project Setup\Setup.vdproj
Logs:
2017-10-04T17:58:48.7033117Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com" MySolution.sln /Build release /Project Setup\Setup.vdproj
2017-10-04T17:59:12.1156461Z microsoft.visualstudio.telemetry.dll
2017-10-04T17:59:12.1196471Z microsoft.visualstudio.telemetry.dll
2017-10-04T17:59:12.1196471Z microsoft.visualstudio.telemetry.dll
2017-10-04T17:59:12.1196471Z microsoft.visualstudio.telemetry.dll
2017-10-04T17:59:12.1206475Z microsoft.visualstudio.telemetry.dll
2017-10-04T17:59:12.1206475Z microsoft.visualstudio.telemetry.dll
2017-10-04T17:59:12.1206475Z microsoft.visualstudio.extensionmanager.implementation.dll
2017-10-04T17:59:46.2231714Z
2017-10-04T17:59:46.2231714Z Microsoft Visual Studio 2017 Version 15.0.26730.3.
2017-10-04T17:59:46.2231714Z Copyright (C) Microsoft Corp. All rights reserved.
2017-10-04T17:59:46.2231714Z
2017-10-04T17:59:46.2231714Z Some errors occurred during migration. For more information, see the migration report:
2017-10-04T17:59:46.2231714Z d:\a\1\s\UpgradeLog.htm
2017-10-04T17:59:46.4634939Z ========== Build: 0 succeeded or up-to-date, 0 failed, 0 skipped ==========
2017-10-04T17:59:48.5239469Z ##[section]Finishing: Run C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com
EDIT 3:
As per #Marina - MSFT I have tried the Build VS Installer, but it didn't quite work for me. The task competed successfully but it appears the MSI is never actually generated as nothing appears in the artifact drop. Here are the logs from the task:
2017-10-04T20:38:12.1314337Z ##[section]Starting: Create .msi file(s) from VS Installer project(s).
2017-10-04T20:38:12.1314337Z ==============================================================================
2017-10-04T20:38:12.1314337Z Task : DutchWorkz - Build VS Installer(s)
2017-10-04T20:38:12.1314337Z Description : Build .msi file(s) from VS Installer project(s).
2017-10-04T20:38:12.1314337Z Version : 1.2.4
2017-10-04T20:38:12.1314337Z Author : DutchWorkz B.V.
2017-10-04T20:38:12.1324342Z Help : <b>BuildVsInstaller v1.2.4</b>, DutchWorkz B.V. (Robin Paardekam)<br/><br/>Visual Studio Installer projects are not supported by MSBUILD, so a regular build will not generate your installer files (.msi). Use this build-task to build the .msi file(s) for your project by running devenv on the buildagent directly. <br/><br/><b>Dependencies:</b><br/>Dep1: when using VisualStudio 2017, this task will only function properly if you installed it in the default C:\Program Files (x86)\ location.
2017-10-04T20:38:12.1324342Z ==============================================================================
2017-10-04T20:38:15.3883721Z DEBUG: Aggregated: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\..\IDE\devenv.com
2017-10-04T20:38:15.4043950Z Now running (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\..\IDE\devenv.com) with Arguments ("d:\a\1\s\MySolution.sln" /Build "release|any cpu" /Project "d:\a\1\s\Setup\Setup.vdproj" /Out "d:\a\1\b\BuildInstaller_Log_20171004203815.txt")
2017-10-04T20:39:39.8930682Z Done running DevEnv process. Success = True.
2017-10-04T20:39:39.8950669Z The single MSI should be located here: d:\a\1\s\Setup\release\
2017-10-04T20:39:40.0450669Z ##[warning]No .MSI files were found, please check your build-configuration. If this is expected, you might consider to use the default Visual Studio Build task instead of this custom Installer task.
2017-10-04T20:39:40.0560673Z ##[section]Finishing: Create .msi file(s) from VS Installer project(s).
Task config
To Build .msi file by VS installer project, you can use Build VS Installer task in marketplace.
You can specify to build .sln or .vdproj to generate .msi file(s) in Task-mode option.
You have to configure your own build agent to run the build since Visual Studio Installer Projects extension is not installed on the Hosted & Hosted 2017 Agent.
Make sure the VS Installer Projects extension is installed on your own build agent and then you can build the setup project either use command line task with "devenv" or use the "Build VS Installer" task.
And if you get the "8000000A" error like following:
Please following the instruction here to configure your build agent: Solution: An error occurred while validating. HRESULT = '8000000A'.
Then you should be able to build the setup project successfully:
I have an solution with one project. Able to build it via VS GUI.
I want to build it via command prompt. But getting errors:
Command used:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" "C:\Users\xxx\Desktop\WebApplication1\WebApplication1.sln" /t:build
error:
error MSB4019: The imported
project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets"
was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
How to resolve this. Please suggest.
This can happen when Visual Studio is not installed on the machine on which you're attempting to build the project (e.g. a build agent).
Verify VS is installed, or if this isn't an option you could run the following command in the package manager console:
Install-Package MSBuild.Microsoft.VisualStudio.Web.targets
This package will update the .csproj file of your project to use the VS version of the targets if they exist, otherwise a local version contained in the packages folder.
The path of MSBuild should be "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" instead of "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe".
As per Visual Studio Blog: MSBuild is now part of Visual Studio!:
Starting with Visual Studio 2013, the 2013 version of MSBuild will ship as a part of Visual Studio instead of the .NET Framework. This transition allows us to more rapidly evolve MSBuild.
So when you build project via command prompt in Visual Studio 2015, the path of MSBuild should be "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe".
Hope this can help you.