Why bother with dotnet build before dotnet publish? - build

Welp. This seems like the type of question where I'll facepalm seeing the answer.
So...
Why bother with dotnet build before doing a dotnet publish?
build automatically does a restore. Cool.
It seems publish does a build (unless you tell it not to). So... Why bother doing the build if you're going to publish right after? Why not just publish and everything happens in one step?
For further clarity...
I am asking in a basic scenario like:
dotnet build -c Release MyProj
dotnet publish -c Release -o /somedir MyProj
versus just
dotnet publish -c Release -o /somedir MyProj
They seem to do the same thing.

You are right that dotnet publish automatically does everything dotnet build already does. In most cases - as in your scenario mentioned in the question - that means an additional dotnet build is not necessary.
Do note that you can dotnet build a solution, but should only dotnet publish individual project files. Publishing solutions likely leads to unexpected results (from overriding files of different versions to publishing library projects in configurations that should not be published to the same output directory as referencing applications etc.)
Over time there was a community ask to allow both publishing and testing without potentially rebuilding the app, because some users felt more comfortable only ever publishing an application with the same binaries that have been tested so their build scripts can look like:
dotnet build the.sln -c Release
dotnet test -c Release --no-build
dotnet publish the\app.csproj --no-build -c Release

Related

Project.UnitTests.dll not found when trying to run unit tests in Azure Devops

The error I am getting :
The test source file "D:\a\_work\3\s\MyProject.UnitTests\bin\Release\net6.0\MyProject.UnitTests.dll" provided was not found.
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
##[warning]No test result files were found.
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
Related yml script:
steps:
- task: DotNetCoreCLI#2
displayName: "Run unit tests"
inputs:
command: test
projects: "**/*MyProject.UnitTests/*.csproj"
arguments: --configuration $(projectBuildConfiguration) --no-build --no-restore
feedsToUse: 'config'
nugetConfigPath: 'nuget.config'
The tests are running all fine in my local machine.
Project build configuration is release
Since you don't have a separate build step you should not be passing the --no-build --no-restore flags.

how to set up sqlite with visual studio 2019

I am setting up a program that requires communicating to a database, but I can not figure out how to set up SQLite for c++ in my ide, I can figure out the rest from there, but the guides are incomplete or inconclusive.
I have tried to work with the api but could not figure out how to install it into my ide, what should i download to get the code for SQLite cpp.
Don't know if you can use dotnet.exe but it's done like this
.Not all projects have these options. Too check project try this command.
Dotnet new webapp -?
Dotnet new mvc -?
Dotnet new winforms -?
Will show -uld |--use-local-db you must use -au Individual
Like this
Dotnet new webapp -au Individual -uld
For SQL server
And Dotnet new webapp -au Individual
For Sqlite.

How to build a FSharp program on Linux just on console?

Is it possible to build a F# program on Linux without IDE, just on console?
Yes, essentially create, build and run an app using the dotnet CLI: dotnet new console -lang F#, dotnet build and dotnet run
More details are in the docs

TFS 2017 - Build and Release

I am very new in TFS, need to implement CICD using TFS 2017 and its build and release feature,
when I tried to run build after creating build definition, I got error like no agent found, I googled and found how to configure agent, but I have logical confusion in my mind as below:
How Agent works with TFS 2017?
Where process of CI will be run on Agent or on TFS server?
Where I need to have msbuild ? where my built code will be placed?
What other dependencies would be there on Agent machine?
all question might be silly but as I have worked with Jenkins and Git, i dont have knowledge of Microsoft technologies, and I can't find well documents for the same.
How Agent works with TFS 2017?
In short to build with TFS, you need to Deploy an agent, in the agent machine you need to install the proper build components/SDKs accordingly based on your project.
Create a build definition. Once a build is triggered , the sources will be downloaded from the TFS repository to the agent machine and then build in the agent machine.
Related documents : Agent pools and queues; Build and Release Agents; Build definition options
Where process of CI will be run on Agent or on TFS server?
You can eanble the CI (turn on the Continuous integration trigger) in build definition. See Configure continuous integration for details. Thus the build will automatically be triggered once changes are checked in.
Related documents: A quick introduction to CI/CD ; Build and release
Where I need to have msbuild ? where my built code will be placed?
For vNext build, it's task based build system. You can define your build definition based on the tasks. See Build and release tasks .
e.g.: You can use MSBuild or Visual Studio Build task, you can specify the MSBuild Arguments as needed.
You can use the utility task: Copy and Publish Build Artifacts and Publish Build Artifacts to specify where the built code will be placed. (Artifact Type : Server/File share path)
What other dependencies would be there on Agent machine?
Refer to the answer for the first question.

How debug wso2 Emm version 2 java souce code?

I want to do some cutomization to the wso2 mdm-product source code (EMM version 2) : https://github.com/wso2/product-mdm
Indeed, when i made some modification to the source code, i need at least 15 min to build the maven projet with eclipce IDE.
Is there other solution to build project directly on carbon server?
How can we debug project with eclipse IDE on carbon IDE?
Usually, it takes some amount of time to build the WSO2 product-mdm, in your case, 15 minutes looks perfectly normal. I'd recommend building the source code using the terminal as follows.
Navigate to the repository directory
cd [path-to-dir]/product-mdm
Perform a clean Maven Build
mvn clean install
If you're unclear about the building process of WSO2 EMM Repositories, the answer on below question might help you to understand the building order.
How to use and understand wso2 git repositories?
Debugging
Remote debugging the project is easy.
Setup the Eclipse IDE for remote debugging as described in this link,
Debugging With Eclipse
Navigate to "[EMM_HOME]/bin/" folder and run the server in debug mode.
sh ./wso2server.sh -debug [specify-port-here]
eg: sh ./wso2server.sh -debug 5005
Once the server is up, you can start debugging.