CN103077038B - The method of dynamic generation and compiling .NET project - Google Patents
The method of dynamic generation and compiling .NET project Download PDFInfo
- Publication number
- CN103077038B CN103077038B CN201310040887.2A CN201310040887A CN103077038B CN 103077038 B CN103077038 B CN 103077038B CN 201310040887 A CN201310040887 A CN 201310040887A CN 103077038 B CN103077038 B CN 103077038B
- Authority
- CN
- China
- Prior art keywords
- project
- under
- file
- class
- compile
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Abstract
The invention discloses a kind of method of dynamic generation and compiling .NET project, comprise the following steps: step one, build project templet according to the overall architecture of project and form the class template of project templet; Step 2, create project folder, under the item file under the project templet comprising class template is copied to project folder, and compile; Step 3, system acceptance parameter information, read the class template under project folder, call text template host instrument, and according to the class file under the parameter information generation class template received under the specified folder be positioned under project folder; Project team's node of step 4, amendment item file, increases compiling node, under the guide of node, is added in project by the class file of generation under this node.Method of the present invention makes software developer simply can realize dynamic generation and the compilation process of project, and avoids the code development work of repetition, is size of code few, and do not rely on development environment Visual? Studio.
Description
Technical field
The present invention relates to field of computer technology, more particularly, relate to dynamic generation and the compiling of .NET project, can be applicable to all needs dynamically to generate and compile in the product of .NET project.
Background technology
Often need dynamically generate and compile project in the performance history of software, software can be made so operationally to generate flexibly according to specific needs and load project.The generation that current .NET commonly uses and the method for compiling project utilize code building under CodeDom assembly and Compile interface.But the exploitation of this method is complicated, size of code is large, and if when needing the multiple project of dynamic creation, there will be a lot of code development repeated.Also have in addition and use msbuild order to compile project, this method needs in code, to call dos order perform, by Software deployment to after serving through the problem of authority often run into.
Summary of the invention
The present invention is directed to the drawback of prior art, a kind of method of dynamic generation, compiling .NET project is provided, make software developer simply can realize dynamic generation and the compilation process of project, and avoid the code development work of repetition, size of code is few, and does not rely on development environment VisualStudio.
In order to solve in existing method the problem that exploitation is complicated, size of code is large, the invention provides a kind of effective method to make dynamically generate to get up with compiling project development more simple, size of code is few.
Before introducing technical scheme, first introduce the implication of project templet and class template, these templates need to be ready in advance.
1) project templet is exactly whole project framework, be exactly the template of solution project: take out the file structure of project and the item of needs according to item types, under being put into the file of project templet, and the content in item file .csproj i.e. solution file is modified, the mode of variable item parameter <#param#> is replaced.
2) class template, it is the subtemplate under project templet: according to the T4 template class file needing in project to create.Usual class template is .cs class file.
Technical scheme of the present invention is as follows:
1) create project folder, copy project template file folder under file under project folder, also to compile.Parameter information in amendment item file .csproj, such as project name etc., preserve item file .csproj.
2) parameter information of system acceptance Dictionary < string, string > dictionary type, reads class template, by information in parameter information alternate template, forms class file.Call text template host instrument (for text template transform engine provides running environment), generate class file to (it is under project folder) under specified folder according to the parameter information received.The ItemGroup node of amendment .csproj file, increases Compile node, is added in project by the class file of generation under this node.
3) the BuildProjectFile method compiling project under the Engine class that provides of system call .NET, generates dll and presss from both sides to corresponding document.
The present invention adopts template method, by being total to the equal templating of anything altogether in anything and class in project, avoids the performance history of constructive process and the complexity repeated in codedom mode.On the other hand, TextTransform.exe instrument is not used when generating class file according to class template, but the self-defined text template host instrument using oneself to write, it does not rely on VisualStudio instrument, this reduces the requirement of running software to environment.
The present invention individual packages can become assembly, and can be applied to all needs dynamically to generate and compile in the software product of .net project.
Accompanying drawing explanation
Fig. 1 is process flow diagram of the present invention, can further show ultimate principle of the present invention.
Embodiment
Below in conjunction with accompanying drawing, the present invention is described in further detail, can implement according to this with reference to instructions word to make those skilled in the art.
As shown in Figure 1, method of the present invention comprises:
1) create project folder, copy content in template project folder under this file.
2) item file .csproj is revised.
3) self-defined text template host is called, the parameter information generation class file reading class template and import into.
4) judge whether class file generates successfully, if failure, return project failed regeneration, if success, continue.
5) class file is added in project by amendment item file .csproj.
6) compile project, if compile unsuccessfully, return project failed regeneration, if success, the project of returning generates successfully.
Specifically, the invention discloses a kind of method of dynamic generation and compiling .NET project, comprise the following steps:
Step one, to build project templet according to the overall architecture of project and form the class template of project templet;
Step 2, create project folder, under the item file under the project templet comprising class template is copied to project folder, and compile;
Step 3, system acceptance parameter information, read the class template under project folder, call text template host instrument, and according to the class file under the parameter information generation class template received under the specified folder be positioned under project folder;
Project team's node of step 4, amendment item file, increases compiling node, under the guide of node, is added in project by the class file of generation under this node.
In the method for described dynamic generation and compiling .NET project, described item file is the file of .csproj type.
In the method for described dynamic generation and compiling .NET project, described step one comprises and takes out the file structure of project and the item of needs according to item types, is built into project templet.
In the method for described dynamic generation and compiling .NET project, the compiling in described step 2 comprises modifies the content in item file .csproj, the mode of variable item parameter <#param#> is replaced.
In the method for described dynamic generation and compiling .NET project, described class file is the file of .cs type.
In the method for described dynamic generation and compiling .NET project, the content in item file .csproj is modified and comprises the amendment of project name.
In the method for described dynamic generation and compiling .NET project, described parameter information is the parameter information of dictionary type.
In the method for described dynamic generation and compiling .NET project, also comprise step 5: the amended item file that system call step 4 generates, then compile project after step 4, the final dll that generates presss from both sides to corresponding document.
Although embodiment of the present invention are open as above, but it is not restricted to listed in instructions and embodiment utilization, it can be applied to various applicable the field of the invention completely, for those skilled in the art, can easily realize other amendment, therefore do not deviating under the universal that claim and equivalency range limit, the present invention is not limited to specific details and illustrates here and the legend described.
Claims (7)
1. dynamically generate and compile a method for .NET project, it is characterized in that, comprise the following steps:
Step one, to build project templet according to the overall architecture of project and form the class template of project templet;
Step 2, create project folder, under the item file under the project templet comprising class template is copied to project folder, and compile;
Step 3, system acceptance parameter information, read the class template under project folder, call text template host instrument, and according to the class file under the parameter information generation class template received under the specified folder be positioned under project folder;
Project team's node of step 4, amendment item file, increases compiling node, under the guide of described compiling node, adds in project by the class file of generation under this node;
The amended item file that step 5, system call step 4 generate, then compile project, the final dll that generates presss from both sides to corresponding document.
2. the method dynamically generating and compile .NET project as claimed in claim 1, it is characterized in that, described item file is the file of .csproj type.
3. as claimed in claim 1 dynamically to generate and the method for compiling .NET project, it is characterized in that, described step one comprises and takes out the file structure of project and the item of needs according to item types, is built into project templet.
4. the method dynamically generating and compile .NET project as claimed in claim 2, it is characterized in that, compiling in described step 2 comprises modifies the content in item file .csproj, the mode of variable item parameter <#param#> is replaced.
5. the method dynamically generating and compile .NET project as claimed in claim 1, it is characterized in that, described class file is the file of .cs type.
6. the method dynamically generating and compile .NET project as claimed in claim 4, it is characterized in that, the content in item file .csproj being modified comprises the amendment of project name.
7. the method dynamically generating and compile .NET project as claimed in claim 4, it is characterized in that, described parameter information is the parameter information of dictionary type.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310040887.2A CN103077038B (en) | 2013-01-31 | 2013-01-31 | The method of dynamic generation and compiling .NET project |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310040887.2A CN103077038B (en) | 2013-01-31 | 2013-01-31 | The method of dynamic generation and compiling .NET project |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103077038A CN103077038A (en) | 2013-05-01 |
CN103077038B true CN103077038B (en) | 2016-03-30 |
Family
ID=48153576
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310040887.2A Active CN103077038B (en) | 2013-01-31 | 2013-01-31 | The method of dynamic generation and compiling .NET project |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103077038B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104267967B (en) * | 2014-10-15 | 2018-06-26 | 北京国双科技有限公司 | The generation method and device of the program code of software |
CN104408120B (en) * | 2014-11-26 | 2019-04-12 | 北京国双科技有限公司 | The processing method and processing device of source code |
CN108563440B (en) * | 2018-04-26 | 2021-09-07 | 武汉斗鱼网络科技有限公司 | Automatic adding method and device of list controller codes and readable storage medium |
CN113191739B (en) * | 2021-05-18 | 2023-10-13 | 上海云扩信息科技有限公司 | Cloud expansion RPA flow project structure and dgs file |
CN113434146A (en) * | 2021-06-22 | 2021-09-24 | 青岛海尔科技有限公司 | Code compiling method, device, storage medium and electronic device |
CN113971444A (en) * | 2021-10-26 | 2022-01-25 | 飞马智科信息技术股份有限公司 | Method for printing two-dimensional code based on WINCC platform |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1896954A (en) * | 2006-04-27 | 2007-01-17 | 南京联创科技股份有限公司 | Method for realizing structural dynamic compiler of complicated multi-service |
CN102368216A (en) * | 2011-10-20 | 2012-03-07 | 北京金和软件股份有限公司 | Process implementation method based on automatic project building |
CN102375743A (en) * | 2011-10-20 | 2012-03-14 | 北京金和软件股份有限公司 | SOA(Service-Oriented Architecture) system development method based on model and template |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070026374A1 (en) * | 2005-07-26 | 2007-02-01 | Sanregret Robert A | System and method for the delivery of education solutions via handheld devices |
-
2013
- 2013-01-31 CN CN201310040887.2A patent/CN103077038B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1896954A (en) * | 2006-04-27 | 2007-01-17 | 南京联创科技股份有限公司 | Method for realizing structural dynamic compiler of complicated multi-service |
CN102368216A (en) * | 2011-10-20 | 2012-03-07 | 北京金和软件股份有限公司 | Process implementation method based on automatic project building |
CN102375743A (en) * | 2011-10-20 | 2012-03-14 | 北京金和软件股份有限公司 | SOA(Service-Oriented Architecture) system development method based on model and template |
Non-Patent Citations (1)
Title |
---|
基于模板的.Net三层架构的代码自动生成;刘于新 等;《计算机技术与发展》;20120831;第13-16页 * |
Also Published As
Publication number | Publication date |
---|---|
CN103077038A (en) | 2013-05-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103077038B (en) | The method of dynamic generation and compiling .NET project | |
CN104714788B (en) | A kind of method and device that software installation packet automatically generates | |
CN102637136B (en) | For the method and apparatus merging the Debugging message from the different compiler stages | |
US8407667B2 (en) | Inferring missing type information for reflection | |
US8239823B2 (en) | Generating libraries for reflection without project compilation | |
US6934940B2 (en) | Source code transformation-temporary object reduction | |
BR112016024522B1 (en) | NON-TRANSITORY COMPUTER READABLE STORAGE MEDIA AND METHOD FOR SPECIALIZING A GENERIC CLASS | |
TWI528288B (en) | Method for transforming application codes in cross-platform and apparatus thereof | |
CN103500087A (en) | Code generation method and device based on maven plug-in and freemarker template | |
KR101770292B1 (en) | Computer-executable model reverse engineering method and apparatus performing the same | |
Keller et al. | File systems deserve verification too! | |
CN103488738A (en) | Method and system for automatically realizing JAVA object and data table SQL (structured query language) file | |
CN113672204A (en) | Interface document generation method, system, electronic equipment and storage medium | |
CN110187886A (en) | A kind of documentation website generation method and terminal | |
CN106547537B (en) | Method for realizing assembled electric power application software based on QML technology | |
Andreotti et al. | Carcara: An efficient proof checker and elaborator for SMT proofs in the Alethe format | |
CN104462157A (en) | Method and device for secondary structuralizing of text data | |
WO2020211074A1 (en) | Multi-party secure computing data processing method, apparatus and system | |
Quesada et al. | A domain-specific language for abstract syntax model to concrete syntax model mappings | |
Kramer et al. | Reflection in attribute grammars | |
CN112181398A (en) | Configuration file processing device, method and storage medium | |
Buchmann et al. | Mapping features to domain models in fujaba | |
JP7393404B2 (en) | Compiling method, compiling device, electronic device, storage medium and program | |
KR101277145B1 (en) | Method For Transforming Intermediate Language by Using Common Representation, System And Computer-Readable Recording Medium with Program Therefor | |
Sjölund | Bidirectional External Function Interface Between Modelica/MetaModelica and Java |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |