Answered by:
Help needed in building

Question
-
User1489758560 posted
Hello,
I would to build the asp.net core solution from command line. for the .net framework, i use the below code which is in .bat file
@Echo OFF Echo "Building solution/project file using batch file" SET PATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319\ SET SolutionPath=D:\Test\SampleTestBuild.sln Echo Start Time - %Time% MSbuild %SolutionPath% /p:Configuration=Debug /p:Platform="Any CPU" Echo End Time - %Time% Set /p Wait=Build Process Completed...
Like this, i would need to create one for building/Compiling the .net core solution from command line. please share me the sample code.
Monday, April 6, 2020 2:47 PM
Answers
-
User711641945 posted
Hi born2win,
all other projects are building properly and only two of them fails with the error message mentioned below. i have tried to check the project file and i have proper version mentioned.Are you sure you use the same command line and only two projects do not work?Actually,when i use your command line it always make such error.It works well by using the following command:
dotnet build D:\Test\SampleTestBuild.sln -f netcoreapp2.2
Best Regards,
Rena
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 7, 2020 6:15 AM -
User475983607 posted
The switch is
dotnet build -f netcoreapp2.2
NOT
dotnet build -f .netcoreapp2.2
Why are you adding the dot? All you have to do is follow the openly published documentation.
https://docs.microsoft.com/en-us/dotnet/standard/frameworks
Lastly, if you issue leave the framework version off the build will use the project file framework version. Have you tried...
dotnet build
... as recommend 3 times now?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 7, 2020 11:06 AM
All replies
-
User475983607 posted
The ASP.NET Core SDK already has these tools.
Monday, April 6, 2020 2:51 PM -
User1489758560 posted
Hi,
Thank you for the link and i am still struggling .
dotnet build [<PROJECT>|<SOLUTION>] [-c|--configuration] [-f|--framework] [--force] [--interactive] [--no-dependencies] [--no-incremental] [--no-restore] [--nologo] [-o|--output] [-r|--runtime] [-v|--verbosity] [--version-suffix]
i am not sure how to build it. this is confusing me. please give me the direct command if possible. appreciate your help.
Monday, April 6, 2020 4:10 PM -
User475983607 posted
Hi,
Thank you for the link and i am still struggling .
dotnet build [<PROJECT>|<SOLUTION>] [-c|--configuration] [-f|--framework] [--force] [--interactive] [--no-dependencies] [--no-incremental] [--no-restore] [--nologo] [-o|--output] [-r|--runtime] [-v|--verbosity] [--version-suffix]
i am not sure how to build it. this is confusing me. please give me the direct command if possible. appreciate your help.
To do what exactly? Build a project? The following builds a project in the current directory.
dotnet build
If you need to change directory then...
CD path\to\the\directory
dotnet buildIf you are interested in learning the command switches then scroll down the page and read.
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build
Monday, April 6, 2020 4:31 PM -
User1489758560 posted
Hi,
I have tried this way
dotnet build -o D:\Test\SampleTestBuild.sln -f .netcoreapp2.2
but getting error as
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
any suggestion to fix the error
Monday, April 6, 2020 4:36 PM -
User475983607 posted
It seems you are not reading reference documentation as -o means output. Anyway the error message is extremely clear. There's no project or solution where you are running the command.
Just CD to solution directly and enter...
dotnet build
This will build to the current version in your project files.
Monday, April 6, 2020 4:48 PM -
User-474980206 posted
the correct command is:
dotnet build D:\Test\SampleTestBuild.sln -f .netcoreapp2.2
note the -f <framework> must match what's in the project file. also .netcoreapp2.2 is obsolete. you should fall back 2.1 LTS or upgrade 3.1 LTS
Monday, April 6, 2020 7:20 PM -
User1489758560 posted
Thank you Bruce and Mgebhard.
i am able to build from command line .but getting below error.
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(93,5): error NETSDK1013: The TargetFramework value '.netcoreapp2.2' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly.
i have 10 .net core class library projects in my the solutions and all are pointing to .net core 2.2. all other projects are building properly and only two of them fails with the error message mentioned below. i have tried to check the project file and i have proper version mentioned.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" /> </ItemGroup> </Project>
then i tried to get the .net info from cmd and i have the blow information.
Microsoft Windows [Version 10.0.17134.1304] (c) 2018 Microsoft Corporation. All rights reserved. .NET Core SDK (3.0.100) Usage: dotnet [runtime-options] [path-to-application] [arguments] Execute a .NET Core application. runtime-options: --additionalprobingpath <path> Path containing probing policy and assemblies to probe for. --additional-deps <path> Path to additional deps.json file. --fx-version <version> Version of the installed Shared Framework to use to run the application. --roll-forward <setting> Roll forward to framework version (LatestPatch, Minor, LatestMinor, Major, LatestMajor, Disable). path-to-application: The path to an application .dll file to execute. Usage: dotnet [sdk-options] [command] [command-options] [arguments] Execute a .NET Core SDK command. sdk-options: -d|--diagnostics Enable diagnostic output. -h|--help Show command line help. --info Display .NET Core information. --list-runtimes Display the installed runtimes. --list-sdks Display the installed SDKs. --version Display .NET Core SDK version in use. SDK commands: add Add a package or reference to a .NET project. build Build a .NET project. build-server Interact with servers started by a build. clean Clean build outputs of a .NET project. help Show command line help. list List project references of a .NET project. msbuild Run Microsoft Build Engine (MSBuild) commands. new Create a new .NET project or file. nuget Provides additional NuGet commands. pack Create a NuGet package. publish Publish a .NET project for deployment. remove Remove a package or reference from a .NET project. restore Restore dependencies specified in a .NET project. run Build and run a .NET project output. sln Modify Visual Studio solution files. store Store the specified assemblies in the runtime package store. test Run unit tests using the test runner specified in a .NET project. tool Install or manage tools that extend the .NET experience. vstest Run Microsoft Test Engine (VSTest) commands. Additional commands from bundled tools: dev-certs Create and manage development certificates. fsi Start F# Interactive / execute F# scripts. sql-cache SQL Server cache command-line tools. user-secrets Manage development user secrets. watch Start a file watcher that runs a command when files change. Run 'dotnet [command] --help' for more information on a command. C:\Users\Rup>dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26 Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100\ Host (useful for support): Version: 3.1.1 Commit: a1388f194c .NET Core SDKs installed: 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.502 [C:\Program Files\dotnet\sdk] 2.1.509 [C:\Program Files\dotnet\sdk] 2.2.101 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
from the .net info, i can see base path pointing to C:\Program Files\dotnet\sdk\3.0.100\ will this causing issue? am not sure. i know, 2.2 is obsolete now. but right now i have to go with this.. so please help me solve this build errors.
Tuesday, April 7, 2020 1:09 AM -
User711641945 posted
Hi born2win,
all other projects are building properly and only two of them fails with the error message mentioned below. i have tried to check the project file and i have proper version mentioned.Are you sure you use the same command line and only two projects do not work?Actually,when i use your command line it always make such error.It works well by using the following command:
dotnet build D:\Test\SampleTestBuild.sln -f netcoreapp2.2
Best Regards,
Rena
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 7, 2020 6:15 AM -
User475983607 posted
The switch is
dotnet build -f netcoreapp2.2
NOT
dotnet build -f .netcoreapp2.2
Why are you adding the dot? All you have to do is follow the openly published documentation.
https://docs.microsoft.com/en-us/dotnet/standard/frameworks
Lastly, if you issue leave the framework version off the build will use the project file framework version. Have you tried...
dotnet build
... as recommend 3 times now?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 7, 2020 11:06 AM -
User1489758560 posted
Hello Rena, your solution worked. Thank you.
Tuesday, April 7, 2020 11:33 AM -
User1489758560 posted
Hello Mgebhard,
Thanks a lot for the help. just a build command also worked like charm. so could you please confirm me that if i need to make this work on fresh machine(2012 server- this is going to be build server), just installing .net core SDK proper version(In my case 2.2) will it be enough?
Tuesday, April 7, 2020 12:08 PM -
User475983607 posted
Thanks a lot for the help. just a build command also worked like charm. so could you please confirm me that if i need to make this work on fresh machine(2012 server- this is going to be build server), just installing .net core SDK proper version(In my case 2.2) will it be enough?If you have to ask this question then you are not taking the time to learn the key concepts. I'm going from your responses above which indicate you are not reading the documentation or the error messages. Maybe there is a language barrier that getting in the way - I'm not sure. I know the ASP.NET Core framework docs are globalized and you should be able to read the docs in your native language.
To answer your question, dotnet build, works exactly as written in the openly published documentation. The behavior does not change if the CLI command is running on another system. Of course, you must install the ASP.NET core SDK on the build server.
Tuesday, April 7, 2020 12:37 PM -
User1489758560 posted
Thank you for the response and i gone through the documentation. I am pretty new to .net core. that's why getting struggle. the reason why asked this question because of ,in my developer machine, i have all necessary software and sdk's installed. we have fresh machine as build server and i will have to work with cruise control with ant script to down load the code from svn and make the automatic build. for the .net framework i am able to acheive. but for .net core, i was struggled and initiated this thread.
Thanks a lot for your time on this thread. appreciated all your responses and knowledge sharing.
Tuesday, April 7, 2020 12:51 PM