1
1
//css_ref \Prototyping\cppscriptcore\ScriptEngine\packages\Microsoft.VisualStudio.Shell.15.0.15.0.26228\lib\Microsoft.VisualStudio.Shell.15.0.dll
2
2
//css_ref C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\EnvDTE80.dll
3
- //css_ref \Prototyping\cppscriptcore\ScriptEngine\ bin\Debug \ScriptEngine.dll
3
+ //css_ref \Prototyping\cppscriptcore\bin\ScriptEngine.dll
4
4
//css_ref \Prototyping\cppscriptcore\ScriptEngine\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll
5
5
//css_ref \Prototyping\cppscriptcore\ScriptEngine\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6071\lib\Microsoft.VisualStudio.OLE.Interop.dll
6
6
//css_ref \Prototyping\cppscriptcore\ScriptEngine\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll
10
10
//css_ref \Prototyping\cppscriptcore\ScriptEngine\packages\Microsoft.VisualStudio.Shell.Framework.15.0.26228\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll
11
11
//css_ref C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\EnvDTE.dll
12
12
//css_ref C:\Prototyping\cppscriptcore\bin\ScriptEngineStarter.exe
13
+ //css_ref C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.VCProjectEngine.dll
13
14
//css_include ..\VSModelSync\CodeBuilder.cs
14
15
using EnvDTE ;
15
16
using EnvDTE80 ;
16
17
using Microsoft . VisualStudio . Shell ;
18
+ using Microsoft . VisualStudio . Shell . Interop ;
19
+ using Microsoft . VisualStudio . VCProjectEngine ;
17
20
using ScriptEngine ;
18
21
using System ;
19
22
using System . Collections . Generic ;
23
26
using System . Reflection ;
24
27
using System . Text ;
25
28
using System . Threading . Tasks ;
29
+ using Constants = EnvDTE . Constants ;
26
30
27
31
public class vsDev
28
32
{
29
33
public static bool Main ( object arg )
30
34
{
31
- Solution solution = ( ( ScriptEnginePackage ) arg ) . dte . Solution ;
35
+ ScriptEnginePackage sepkg = ( ScriptEnginePackage ) arg ;
36
+ Solution solution = sepkg . dte . Solution ;
32
37
33
38
ScriptHost . console . Clear ( ) ;
34
39
ScriptHost . console . WriteLine ( "Build: " + Assembly . GetExecutingAssembly ( ) . Location ) ;
@@ -45,6 +50,8 @@ public static bool Main( object arg )
45
50
// The "Miscellaneous Files" node is used to contain open files that are not associated
46
51
// with the current project contents within the solution
47
52
//
53
+ // https://stackoverflow.com/questions/7160425/what-is-miscellaneous-files-inside-dte-vs2010-solution
54
+ //
48
55
if ( project . Kind == Constants . vsProjectKindMisc )
49
56
continue ;
50
57
@@ -62,19 +69,58 @@ public static bool Main( object arg )
62
69
class Builder: SolutionProjectBuilder
63
70
{
64
71
static void Main(String[] args)
65
- {
66
- " ) ;
72
+ {" ) ;
67
73
code . Indent ( 2 ) ;
74
+
75
+ String name = project . Name ;
76
+ code . AppendLine ( "project(" + quoted ( name ) + ");" ) ;
77
+
78
+ Configuration [ ] configurations = project . ConfigurationManager . Cast < Configuration > ( ) . ToArray ( ) ;
79
+ code . AppendLine ( "configurations(" + String . Join ( "," , configurations . Select ( x => quoted ( x . ConfigurationName ) ) . Distinct ( ) ) + ");" ) ;
80
+
81
+ IVsHierarchy hierarchy ;
82
+ sepkg . vsSolution . GetProjectOfUniqueName ( project . UniqueName , out hierarchy ) ;
83
+ Guid projectGuid ;
84
+ hierarchy . GetGuidProperty ( Microsoft . VisualStudio . VSConstants . VSITEMID_ROOT , ( int ) __VSHPROPID . VSHPROPID_ProjectIDGuid , out projectGuid ) ;
85
+
86
+ code . AppendLine ( "uuid(" + quoted ( projectGuid . ToString ( ) ) + ");" ) ;
87
+
88
+ VCProject vcProject = project . Object as VCProject ;
89
+ VCFile [ ] files = ( ( IVCCollection ) vcProject . Files ) . Cast < VCFile > ( ) . ToArray ( ) ;
90
+ String [ ] paths = files . Select ( x => x . RelativePath ) . ToArray ( ) ;
91
+
92
+ code . AppendLine ( "files(" ) ;
93
+ code . Indent ( ) ;
94
+ for ( int i = 0 ; i < paths . Length ; i ++ )
95
+ {
96
+ code . Append ( code . IndentString + quoted ( paths [ i ] ) ) ;
97
+
98
+ if ( i != paths . Length - 1 )
99
+ code . Append ( "," ) ;
100
+
101
+ code . Append ( "\r \n " ) ;
102
+ }
103
+ code . UnIndent ( ) ;
104
+ code . AppendLine ( ");" ) ;
105
+
68
106
code . UnIndent ( ) ;
69
107
code . AppendLine ( "}" ) ;
70
108
code . UnIndent ( ) ;
71
109
code . AppendLine ( "}" ) ;
72
110
111
+ ScriptHost . console . WriteLine ( "Saving " + script + "..." ) ;
73
112
File . WriteAllText ( script , code . ToString ( ) ) ;
74
113
}
75
114
return false ;
76
115
}
77
116
117
+
118
+ public static String quoted ( String s )
119
+ {
120
+ return "\" " + s . Replace ( "\" " , "\\ \" " ) + "\" " ;
121
+ }
122
+
123
+
78
124
}
79
125
80
126
0 commit comments