Teach you to build WPF official open source framework source code, wpf development language

1 year ago (2023-12-05) Chief Editor
16 minutes
three hundred and forty-six
zero

Microsoft has opened WPF since last year, and almost all WPF source codes are now open source. When learning the framework, I will make some changes, hoping to build my own version for testing. However, as a particularly large framework, building and running can not be completed directly by clicking Run in Visual Studio. It requires a lot of preparation. This article will teach you how to build WPF framework source code step by step

I dare not say that I can build the source code of each version of WPF framework in the official repository // github.com/dotnet/wpf The successful version I build is that this commit partner can try to use the method in this article. The commit that is cut first is built according to my method, and then try to update the version after success

Read this article to let you know how to build WPF framework // github.com/dotnet/wpf Source code, but it is not guaranteed that you can build successfully

The steps to build WPF are as follows:

Download the dependent libraries required for construction

Restore NuGet Package

Build C++and C # codes in order to create NuGet packages

For our domestic partners, the most problematic problem is to download and build the required libraries, which are as follows

Dotnet-sdk-5.0.100-preview.1.20155.7-win-x64.zip Install

Dotnet-runtime-5.0.0-preview.4.20220.15-win-x86.zip Install

Strawberry perl-5.28.1.1-1-win64-x64.zip to the. netcoreengnativetemp folder

Net-framework-48-ref-assemblies-0.0.0.1-win64-x64.zip to the. netcoreengnativetemp folder

Dotnet-api-docs_netcoreapp3.0-0.0.0.2-win64-x64.zip to the. netcoreengnativetemp folder

Msvcurt-c1xx--0.0.1.2-win64-x64.zip to the. netcoreengnativetemp folder

Net-framework-472-iltools-0.0.0.1-win64-x64.zip to the. netcoreengnativetemp folder

Dotnet runtime 2.1.7-win-x86.zip installation

The. netcoreengnativetemp folder mentioned above is under the user name, such as C: Userslindexi.netcoreengnativetemp folder

These files are very large. At the same time, some files will be downloaded and placed in the temporary folder of the system. If the download fails at the first time, no verification will be performed the second time, only an IO decompression error will occur. At this time, you need to clear your own system temporary folder, user temporary folder and C: Userslindex.netcoreengnativetemp folder

When building, you also need to let Visual Studio install almost all the loads that can be installed. After all, you need to build something like C++, which also requires the Visual Studio version. The minimum Visual Studio requirement is version 16.4

At present, I certainly won't say such a way at the beginning. The failure rate of local construction is too high. Even if I download all of them with ladders, I can't succeed, because one thing lies in the code built. Microsoft's partners think that the network speed is very fast, and if the download is not completed within a certain time, it is a failure. And I basically failed to download it every time. At the same time, after the failure, no verification is done next time, that is, unless I delete all of them and download again, the car may roll over because the download is not completed and the build is half completed

A simple method is to use GitHub's Action to build. Thanks to Microsoft, Microsoft has bought GitHub to support a large number of local tyrants. All children can use GitHub's Action to build code for free as long as they create GitHub accounts. The built server can choose Windows full environment server. The latest Visual Studio and all loads are installed in the server, which has complete functions. The download and installation network speed is basically 100M per second. The important thing is that such a powerful server is free of charge, and it will be executed automatically as long as the build script is written

Okay, almost the advertising expenses have been paid. Let me tell you how to use GitHub's Action to build WPF framework source code

Tell me why before you start

The first reason is the environment, because WPF code contains part of C++code, which is specially tuned to the environment. You need to install almost all the features of Visual Studio. I just rolled over here. I installed one less and then the car rolled over. But it is hard to guess that it was less installed because the prompt is very strange. Although I give Visual Studio all the functions in one sentence, I don't expect you to listen to me

The second reason is the network speed. The package to be downloaded is still a bit large. At the same time, the server to restore NuGet has no domestic source

It just happens that all GitHub actions can meet the conditions, including all environments, and the download speed is particularly fast

The way to use GitHub's Action is to create a build manifest file and place it in the. githubworkflows folder. The manifest file is in yml format, such as dotnetcore. yml file

The format of the list file is not our focus. Theoretically, the little partner can understand it after reading the code, and does not need to learn

name: . NET Core
on: [push]
jobs: build:
runs-on: windows-latest
steps: - uses: actions/ checkout@v1 - name: Install Nuget uses: nuget/ setup-nuget@v1 with: nuget-version: 5.x - name: Build run: .build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86

Yes, put the manifest file in the manifest folder, such as the commit method, so that WPF can be built

The above listing file is also the simplest code for WPF to build. The core code is. build.cmd - pack - ci - configuration Release - prepareMachine/p: Platform=x86. Through this code, you can call the script written by Microsoft partners to build

If you see the output in the log and build the nupkg file, the build is successful

2021-04-23T04:00:24.5493423Z Successfully created package D:awpfwpfartifactspackagesReleaseNonShippingruntime.win-x86.Microsoft. DotNet. Wpf. GitHub.5.0.0-ci.nupkg.2021-04-23T04:00:40.3376680Z Successfully created package D:awpfwpfartifactspackagesReleaseNonShippingMicrosoft. DotNet. Arcade. Wpf. Sdk.5.0.0-ci.nupkg.2021-04-23T04:00:41.1278940Z Successfully created package D:awpfwpfartifactspackagesReleaseNonShippingMicrosoft. DotNet. Wpf. GitHub.5.0.0-ci.nupkg.2021-04-23T04:00:42.2993941Z Successfully created package D:awpfwpfartifactspackagesReleaseNonShippingMicrosoft. DotNet. Wpf. ProjectTemplates.5.0.0-ci.nupkg.2021-04-23T04:00:43.0266336Z Successfully created package D:awpfwpfartifactspackagesReleaseNonShippingMicrosoft. NET. Sdk. WindowsDesktop.5.0.0-ci.nupkg.2021-04-23T04:00:45.5485389Z 2021-04-23T04:00:45.5486750Z Build succeeded.2021-04-23T04:00:45.5488608Z 0 Warning(s)2021-04-23T04:00:45.5489064Z 0 Error(s)2021-04-23T04:00:45.5489325Z 2021-04-23T04:00:45.5921119Z Time Elapsed 00:05:29.82

That is, the simplest way to build WPF is to first transfer the Fork official warehouse to its own warehouse, clone the WPF code to the local, switch the commit to the f226a72ed5302737b14984cffdd6208731244038 version, and use the Git command below to switch the commit

git checkout f226a72ed5302737b14984cffdd6208731244038

Then create a new branch and use the Git command as follows

Git checkout - b branch name

Copy the code of the above listing file, create the dotnetcore.yml file in the. git folder relative to the. git folder, and put the above listing code into the dotnetcore.yml file

Use Git to create a commit or use Visual Studio team management to create a commit and push it to your Fork warehouse. At this time, the automatic construction of GitHub's Action will be triggered

The output of the built WPF is the NuGet package, which is located in the artifactspackages folder

After the construction is successful, please try to switch the source code of WPF to the latest and try to build it

The locally built method is relatively complex. Although we can see from the above listing file, the built code only calls the script. However, the local environment needs to be built first, such as allowing Visual Studio to install all functions

The local building method is as follows

Open Visual Studio first and let Visual Studio install all the functions, especially all the C++checks

Keep local system is the latest version of Windows 10

Download the Windows Driver Kit (WDK) installation. I'm not sure if this is necessary

Build the ladder and set the global proxy

Execute the. build.cmd script through PowerShell. Be careful not to add any suffix at this time, so that you can quickly know whether the download failed in the output information

If the download fails, you will be prompted, such as decompression failure. At this time, please clear your system temporary folder, user temporary folder, and. netcoreeng folder. The. netcoreeng here is placed in the user folder, such as the C: Userslindexi.netcoreeng folder. Empty NuGet cache folder. Call git clean - xdf to empty the code file

You can find the link of the file to be downloaded through the output of the ladder. You can try to be a local agent, download it in other ways first, and then use Fiddler to simulate the path to increase the download speed

If the following code can be output, it means that the previous download tool should be completed

LINK : fatal error LNK1104: cannot open file MSVCURTD_netcore. LIB [D:awpfwpfsrcMicrosoft.DotNet.WpfsrcDirectWriteForwarderDirectWriteForwarder.vcxproj]

The above code is because the x86 mode is not specified. Run. build.cmd - pack - ci - configuration Release - prepareMachine/p: Platform=x86 on the command line to try to build

If it still fails, you can try the above command several times without doing any cleaning. Or first call git clean - xdf to clean up, and then continue to call the above command

After many attempts, you should be able to build successfully. After that, you can open Visual Studio happily and build a project separately. Of course, not all projects can be successfully built

In the commands that call the above script, there are actually the following call methods, which are used to build x86 and x64, and to build Debug and Release

build.cmd -pack -ci -configuration $(Configuration) -prepareMachine /p:Platform=$(Platform)

Please replace $(Configuration) of the above code with Debug or Release and replace $(Platform) with x86 or x64 for construction

If you can generate an official build ID, you can add the following parameters on the command line:/p: OfficialBuildId=$(BuildId). The BuildId here is $(BUILD. BUILDNUMBER) in the official warehouse. This is a parameter in Azure Pipelines. The approximate value is 20190909.1. You can give it as you like

The - ci of the above parameter is a function provided by arcade to start CI building

If you can build official open source code, you can make your own private version. After you use the above command to build, you can find the built NuGet package in the artifactspackages folder. These files can be released privately, or you can modify the ID to release them

Now Microsoft's open source protocol is very friendly, allowing partners to modify and release the source code

Although you can make your own private release, I still recommended that you bring the code to the official warehouse, and the official big man will help you see if the code is reasonable. Use your own version only when the official leaders think the code is unreasonable but they think it is necessary, or the official release is too slow

The reason is that if you use your own version, it will be difficult to merge it into your own version after the official repair of some content

This work is licensed under the Creative Commons Attribution - Noncommercial Use - Sharing in the Same Way 4.0 International License Agreement. This article was first published by [Lin Dexi] on: // blog.csdn.net/lindexi_g d You are welcome to reprint, use and republish the article, but you must keep the article's signature [Lin Dexi].

-----------------------------------

If you need to enter the technical group, please add a small editor zls20210502

This article is written by: Chief Editor Published on Software Development of Little Turkey , please indicate the source for reprinting: //hongchengtech.cn/blog/1867.html
Kuke_WP editor
author

Related recommendations

1 year ago (2024-02-20)

What technologies have been applied and developed in the field of new media, and the application of new technologies in media

In the field of new media, many technologies have been applied and developed. These include: cloud computing: cloud computing technology enables new media companies to develop and deploy applications more quickly, and can dynamically adjust resources according to needs. Big data: New media companies can use big data technology to analyze massive user data, understand user preferences, behavior habits and other information
nine hundred and seventy-one
one
1 year ago (2024-02-20)

WMS warehouse management system, promoting the transformation of warehousing from extensive to fine management, WMS warehouse management

Warehousing is extremely important for the manufacturing industry and is an important guarantee for the survival and development of manufacturing enterprises. However, with the expansion of manufacturing enterprises' business, the traditional warehouse management has been unable to respond to business changes quickly. The extensive management mode not only makes the warehouse operation not smooth, but also increases the storage cost. Therefore, it is necessary for manufacturing enterprises to deploy a WMS warehouse management system
eight hundred and forty-eight
one
1 year ago (2024-02-20)

How to select MES system? Main contents of MES production management

Original title: How to select MES system? The main content of MES production management Production and manufacturing activities are the core activities of manufacturing enterprises. As the entity unit of manufacturing activities, planning objectives and the realization of enterprise value, workshop management is the focus of enterprise management. With the rapid development of manufacturing industry, MES is the focus and current hot spot of manufacturing enterprise information automation system
nine hundred and sixty-four
zero
1 year ago (2024-02-20)

The WeChat management system can manage the information content of WeChat more effectively. Let's manage the data of WeChat here

Original title: WeChat management system manages the information content of WeChat more effectively. Many enterprises will assign work to WeChat, because no one wants their personal WeChat to mix work and other related knowledge, but someone will always use the company's loopholes to do something harmful to the company's interests. Don't think such things are rare. I learned about a media financing company in Shenzhen. They have 3
seven hundred and seventy-seven
zero
1 year ago (2024-02-19)

Student electronic file management system, three-dimensional communication space of "home", "school" and "community", and school electronic files

In the era of big data, in the process of recording the growth of students, the school reexamines the management of student files, moves with the times, and promotes the reform of student growth files with new thinking. "Electronic files of primary and secondary school students' growth records" have been gradually introduced into educational management, and show vigorous vitality. Student file management system is an indispensable part of the school, its content for the school
five hundred and seventy-one
zero
1 year ago (2024-02-19)

Ruizhe Information: Select Sitecore? Or... just six steps to choose a content management system, Ruizhe Information Technology Service Co., Ltd

The content management system (CMS) is an important part of the success of website construction. At present, the content management system on the network is relatively complex. It is not easy to find a good content management system that is very suitable for the current digital marketing environment. Before we compare the functionality, operation, scalability, security and other specific performance of the major CMS systems, we need to achieve
three hundred and forty-three
zero

comment

0 people have participated in the review

Scan code to add WeChat

contact us

WeChat: Kuzhuti
Online consultation: