The construction tool of C ා

Time:2020-2-24

What’s the motivation for writing this article? Why do you want to study the build tool (see. Csproj), create a new C project with visual studio IDE, and click build to run it?

A: please refer to this_minutes_before_coding. I call it “engineering.”. Engineering development is not just about opening IDE and creating new projects. It needs to follow a clear paradigm, and each component has its own role. It has its own meaning, and every component has its own meaning (there are many ways to complete a thing, and a clear plan can help you complete it faster).

You should have reason to write code with any editor you like. It’s just a source file + compilation process + compilation result. All you need to edit is the source file. Any text editor can. IDE is not the only option. (although in the actual large projects, you will use ide because it can help you “save effort”. At present, in some small projects, you don’t need ide to hide some things and processes. The command line can see what happens. And to get the project running, it’s enough to use the right command line: if it’s not enough, it’s the wrong command. You should find the right command, instead of using the IDE to accept its black box style “labor saving”: it’s not good to know what’s going on behind. It’s not interesting (the same result is achieved in two ways), but it’s a kind of obsession)(But it doesn’t work. It sounds like a psychological function)(mainly forLearn msbuild (and csproj) 1 2 3)

Answer: the command line can replace ide. The development of JavaScript is just a variety of tool chains, and the construction tools are very complete. They are all commands in a command line (without IDE). Java development, you can also do without IDE, just javac and Java commands are OK. Then in the face of C ා development, you can also build projects. Of course, it’s obvious to build a project: build a project from visual studio, but you need to fill in the project name and fill in some templates to get the project directory and the files in it. Of course, the command line should be able to do it; run a project: just after you determine the target, build according to the build file, and the command line should be able to do it.
Things to consider:

  • A text document, some command lines, can open the project
  • Projects opened from the command line should be able to be opened in the IDE, and vice versa. There is compatibility here
  • Replace ide with a full command line operation to get the finalProject file (directory structure)Just fine.
  • The final operation of the project: build, compile and run the program to ensure the correct operation of the final program (through the command line or IDE, a few things that can be done by the command line will not be too much of an IDE)
  • The initial creation of the project: just some file generators get a directory structure
  • Granularity: to command behavior
  • Compatibility: you can download some C ා projects on the Internet. Obviously, they are built by ide. I want to find a way to run them in command line mode. At the same time, the C ා projects I built with command line can be opened by ide

What is the build tool?
The build tool [1] will build binary according to the build document [2], which is convenient to run.

Basic feeling: in terms of function,Dotnet run (including dotnet restore + dotnet build + dotnet run - F netstandard2.0)andmsbuild + mono 123.exeTheoretically, it should be the same effect [1], but in fact, the mono system is easy to use, especially to avoid many compatibility problems. Including but not limited todotnet run -f netstandard2.0Problems encountered)

  • /usr/local/share/dotnet/sdk/3.0.100/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.7.2 were not found. To resolve this, Install the developer pack (SDK / targeting pack) for this framework version or retarget your application. You can download. Net Framework Developer packs at https://aka.ms/msbuild/develo… [demo12.gtk/demo12.gtk.csproj] / / solution export frameworkpathoverride
  • Unable to run your project. Ensure you have a runnable project type and ensure ‘dotnet run’ supports this project. A runnable project should target a runnable TFM (for instance, netcoreapp2.0) and have outputtype ‘exe’. The current outputtype is’ winexe ‘. / / solution change csproj to exe
  • Error cs0246: the type or namespace name ‘GTK’ could not be found (are you missing a using directive or an assembly reference?) [demo12. GTK / demo12. GTK. Csproj] / / solution unknown


Build file:

  • Simple build tool: makefile similar to C + +
  • Complex build tool:. Csproj (C ා project csproj file format)

Reference resources
https://blog.lindexi.com/post…
Https://walterlv.com/post/und… ා what’s the difference between the old and new csproj? The targetframeworkversion property is the old format, and the targetframes property is the new format*
Reference resources
https://docs.microsoft.com/en…
https://docs.microsoft.com/en…
Https://www.cnblogs.com/linia… Getting started with msbuild
https://docs.microsoft.com/en…

Be careful:
There are two ways to implement. Net standard: dotnet core and mono. Each of them has its own runtime, so it has its own set of commands (the command of DNC isdotnet run, mono’s command ismsbuild + mono 123.exe, see dotnet mono). But the read build file is the same (. Csproj).

Doubt:
As a package management tool, nuget and dotnet add can download third-party packages. However, it does not seem to deal with the problem of package dependency management (a package has many dependent packages dependency management)?
So we need to introduce Payet 1 2
does dotnet add resolve dependencies
C# dependency management

Doubt:
msbuild + mono 123.exeandDotnet run (including dotnet restore + dotnet build + dotnet run)Relationship
Reference dotnet mono

A genius troubleshooting action, about the failure of dotnet run on MAC / Linux because target is. Net framework
1. Export frameworkpathoverride doesn’t seem to work. It hasn’tmsbuild + mono 123.exeEasy to use
2

Mono system

Runtime for running binary (exe):

  • mono 123.exe

Building tools

  • msbuild

Build files
. csproj (C ා project csproj file format)

position
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono
/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild

Possible commands involved:

  • msbuild
  • csc
  • gcs

Possible commands involved:

  • msbuild 123.csproj -t:build
  • msbuild -t:rebuild
  • msbuild -t:clean
  • msbuild -verbosity:minimal

IDE
MS build and mono are used in vs mac

It may involve compiling commands (. Implementation of net standard):

  • Mono system: CSC, mono, msbuild [1] ()
> which mono
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono
> which msbuild 
/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild 
Supported commands:
msbuild 
msbuild 123.csproj
msbuild -t:rebuild
msbuild -t:clean 
mono bin/Debug/123.exe

https://blog.lindexi.com/post…
https://walterlv.com/post/und…

Dotnet system

Runtime for running binary (exe):

  • dotnet run

Build tools:

  • dotnet build

Build file:

  • . csproj (C ා project csproj file format)

Possible commands involved:

  • dotnet run
  • dotnet run -f netstandard2.0
  • dotnet watch run
  • Dotnet msbuild – t: publish – P: outputpath = pub – P: configuration = release. Refer to https://docs.microsoft.com/en
  • dotnet build
  • dotnet msbuild
  • dotnet restore

Path (MAC):

  • /usr/local/share/dotnet/dotnet

IDE
?

  • Dotnet core: dotnet 12
> which dotnet
/usr/local/share/dotnet/dotnet
Supported commands:
dotnet run
dotnet build
dotnet msbuild
dotnet msbuild -t:rebuild
dotnet msbuild -t:clean

Paket

Payet a package manager for. Net
Used to handle package dependencies, similar to Ruby bundle. It’s equivalent to enhanced nuget

Package management commands may be involved (dependency and download of third-party packages):

  • Packet (also a build tool, a package manager, enhanced nuget, handle package dependency (packet will automatically call nuget to download some third-party packages, which is equivalent to a third-party package download function wrapper, a more powerful third-party package manager), obviously drawing on ror’s bundle and gemfile. The granularity is to explicitly handle the package dependency of third-party packages, which is similar to Ruby bundle and nuget compatible. Similar to gemfile.lock, it has its own packet. Lock) 1 2
  • cake

Recommended Today

Laravel service container must know

The article was forwarded from the professional laravel developer community. Original link: https://learnku.com/laravel/t To learn how to build an application with laravel is not only to learn how to use different classes and components in the framework, but also to remember allartisanCommand or all helper functions (we have Google). Learning to code with laravel is […]