From recompiling xaf to package and deploy GAC

Source: Internet
Author: User

The goal of this topic is to learn and understand some common usage of msbuild by re-compiling the xaf source code and re-subcontracting deployment.

Why is xaf used for learning? The most important reason is that I am using it. The re-Compilation of xaf does not seem to be a toy and can be used in practical use.

What is xaf? If you are familiar with it, you can search for it in the park. In order not to deviate from the subject, we will not introduce it too much here, which will not affect the discussion below. In a few simple words, xaf is an excellent enterprise-level application.ProgramFramework. You only need to handle the actual business logic. The framework will automatically generate a database for you (using the ORM tool xpo in xaf ). The framework can also generate a very powerful UI presentation layer (which uses the devexpress suite) for you ). It sounds like a myth. When you are studying open-source projects, you may wish to look at it, although it is a commercial product. But when you really see his strength, you can't help but sigh, what is the gap between urban and rural areas. If you have no intention of degrading open-source projects, you must have different focuses.

The topic is described in detail. After you install the xaf source code package, you may want to monitor what xaf has done for you through one-step debugging. However, the debugger does not trackSource code. In this case, you need to re-compile the source code package so that the debugger can track the source code inside the DLL. (The xaf source code is also exciting and frustrating ). When you compile a project with vs, a file with the same name as the DLL file but with the suffix. PDB will be generated in the bin directory. When debugging is enabled, the debugger will find the corresponding program source code through this file. The complete xaf source code package contains at least 100 DLL files generated for more than 80 types of projects. Maybe you can't use that much in your project. These DLL references each other. If you need to manually create a solution and add references, it is a very time-consuming and annoying thing. It is gratifying that the official website provides us with a compilation script. In fact, msbuild and gacutil are used to process some batch files.

Let's take a look at some of devexpress's official guidelines for recompilation.

 The following is a simple description:

1. Use its installation package to install the component.

2. Use the SN tool to generate your own strong naming file and copy it to the specified directory.

3. Find all DLL files in the installation directory and delete them. Run the script to clear the Global Assembly Cache of devexpress (GAC.

4. Run the compiling script in the source code directory.

5. Register components in the toolbox.

(Note: if your source code package is not complete, you cannot delete some DLL files)

 

Several steps involved several very important knowledge points and several seemingly uncommon tools.

 

1 Gbit/s hypervisor and sn.exe Tool

Strong names are mainly used by some large companies for unified Assembly naming, and the other is to prevent Assembly forgery. However, Richard grime introduced a method to crack Strong names (http://grimes.demon.co.uk/workshops/fusionwscrackthree.htm ) is a bug Based on clr1.1. microsoft in. this bug was fixed in net2.0, followed by Richard grime

In his article, he added the brute-force password cracking method for versions 2.0/3.0. But in fact, the most awesome cracker comes from China, and the dev registration program is almost synchronized with the official updates (Danny, we are looking forward to yourArticle). When you reference a 3rd-side control, a strong name may cause you some trouble. However, strong names are not mainly used to solve security problems. If you write controls, adding a strong name to your project is required,Only programs with strong names can be placed in GAC. Only a set of programs placed in the GAC can be referenced in the vs toolbox. Therefore, strong names must be used for controls and components.

Use the sn.exe command line tool to create a strong name. Of course, you can also use the visual tool of vs project property-signature to generate the file.

The following commands are commonly used.

It is easier to use the command line than. Next, go to disk D and copy the private key file we just generated to the devexpress. Key \ folder.

 

2. xcopy and GAC

The next thing to do is to delete the DLL file and clear the GAC of the dev component.

. Net Assembly deployment usually has two policies. I like xcopy deployment, without accessing the registry or accessing the window Active Directory. It is cleaner than the messy green version. That is, the installation services with MSI are clean. (One day I happened to find that the so-called green version software is a batch file used to write the registry. Even if a folder is deleted during uninstallation, it will leave garbage in the registry, usually this batch process will also tamper with your home page)

Since xcopy is so easy to use, why does GAC still need it? I think this is what Microsoft needs most. Microsoft designed it to allow its operating system to support. Net versions of the Assembly. For example, if your web application is developed in the 2.0 Environment, your program will reference the 2.0 Assembly DLL in GAC. If it is 3.5, your program will reference version 3.5. Companies that frequently change product versions like Dev are also very useful. It is also possible to consider performance. However, for most enterprise applications, folder deployment is more practical.

How do we view and clear the DLL in GAC? When we install. NET platform will automatically install a file named shfusion. DLL shell extension, which allows us to browse the GAC folder in the resource manager, we can usually when it does not exist. Do not try to modify gac.if you want to modify the gacutil.exe tool used by the. NET folder. Msdn provides two methods to uninstall the GAC assembly.

Use the Windows Interface

  • Navigate to GAC at % systemdrive % \ windows \ assembly.

  • Right-click each Assembly file included in your application, and click "Uninstall"And then click "yes"Confirm.

    Use command line

      1. Open the Visual Studio command prompt as follows: Click Start", Pointing to "all programs" in turn",Microsoft Visual maxcompute 2008, "Tools"And then click "Visual Studio 2008 command prompt".

      2. Enter the following command at the command prompt:

        Gacutil/u<Fully qualifiedAssembly name>

        In this command, the Assembly name is the name of the assembly to be detached from the GAC.

        The following example removes the Assembly named hello. dll from GAC.

        Gacutil/u "Hello, version = 1.0.0.0, culture = neutral, publickeytoken = 0123456789 ABCDE

  • Another more direct method is used in the dev script. This may require you to have the computer administrator privilege.

    RD/S/Q % gacpath % devexpress. Data. % dxver %
    RD/S/Q % gacpath % devexpress. Data. % dxver %. LINQ
    RD/S/Q % gacpath % devexpress. Design. % dxver %

     

    % Gacpath % indicates the global cache directory. You can use the command line tool to directly clear the directory tree. If you use the command line tool to enter the global cache directory, you will find that all the DLL files are actually a directory

    In this way, you can write a batch to uninstall the GAC assembly.

     

    32.16msbuildand msbuild.exe tools

    Msbuild is a relatively large concept designed to unify various compilation technologies in the past. It is a unique XML format. The. proj, csproj, vbproj, and other files generated by vs are all written in msbuild XML format. For more information, see msdn.

    In the process of compiling xaf, only one script with msbuild.exe is used (some substitution characters such as % configuration % = debug are used)

    % Msbuild %/nologo/T: rebuild/verbosity: Quiet/P: configuration = % configuration %; platform = anycpu

    He will automatically search for the target to complete our generation. This process may take some time.

    4. Use gacutil to register the Assembly

    Then register the generated DLL to GAC, and then use the gacutil tool.

    The gacutil.exe tool has many parameters. Common commands are as follows:

    Gacutil/I mydll. dll

    Dev script

    CD devexpress. dll
    % Gacutil %-I devexpress. bonusskins. % dxver %. dll
    % Gacutil %-I devexpress. Data. % dxver %. Compact. dll
    % Gacutil %-I devexpress. Data. % dxver %. dll
    % Gacutil %-I devexpress. officeskins. % dxver %. dll
    % Gacutil %-I devexpress. tutorials. % dxver %. dll
    % Gacutil %-I devexpress. utils. % dxver %. dll
    % Gacutil %-I devexpress. Web. aspxeditors. % dxver %. dll
    % Gacutil %-I devexpress. Web. aspxgridview. % dxver %. dll
    % Gacutil %-I devexpress. Web. aspxgridview. % dxver %. Export. dll

    Run the dev script and all the DLL files will be loaded into the GAC. So far, the DLL compilation generated by registering with the dev toolkit is over.

     

    Next, I want to re-compile the project and re-package it to facilitate distribution to my colleagues, I will carefully read the deployment Methods MSI \ cab \ xcopy \ clickonce and NTD, and then select an appropriate method.

    I hope you can point out the above descriptions. I found that my expression skills are lacking and I hope you will understand it.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.