I have a project file (*.fsproj). It can be built successfully with Visual Studio 2019 via "Build" menu.
But when invoking "Build Tools for Visual Studio 2019" ( link ), with the following command:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe" ".\src\[ProjectFolder]\[ProjectName].fsproj" /t:Build /p:Configuration=Release /p:Platform="Any CPU"
It raised an error error MSB4057: The target "Build" does not exist in the project.
.
The project file:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>2.0.0.0</Version>
<FileVersion>2.0.0.0</FileVersion>
<Configurations>Debug;Release;[...]</Configurations>
</PropertyGroup>
<ItemGroup>
<Compile Include="[File1].fs" />
<Compile Include="[File2].fs" />
<Compile Include="[File3].fs" />
</ItemGroup>
<ItemGroup>
<None Include="paket.references" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Note: To keep names confidential, I replaced them with [].
Question : Is there anyway to make MSBuild behave exactly like what is done in Visual Studio? I'm attempting to build *.SLN (consisting of many *.fsproj and *.csproj), without Visual Studio IDE.
I can force Visual Studio to spit out more logging info when it builds (as followed), but the logging info is overwhelming and I don't know what to look for.
My solution file (*.SLN) includes many sub-project files (*.fsproj, *.csproj). Some projects are written in .NET Standard 2.0 ; others are in .NET Core 3.1 . (aka. Target Framework)
Thanks to the answers 1 and 2 , MSBuild should not be used because some of my projects are targeted to .NET Core. The right compilation tool is dotnet SDK with the following command:
dotnet build --configuration Release "[MySolution].sln"
dotnet
is built on top of MSBuild. It adds some features not available in MSBuild, such as dotnet new
. In addition, to have dotnet
to compile, .NET Core SDK (eg v3.1: link ) must be installed; no need to install MSBuild separately.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.