@@ -6,70 +6,79 @@ namespace ProjectsGenerator
6
6
{
7
7
class Program
8
8
{
9
+ private static readonly string ProjectName = "Lambda2Js" ;
10
+
9
11
static void Main ( string [ ] args )
10
12
{
11
13
Console . WriteLine ( $ "Environment.CurrentDirectory = { Environment . CurrentDirectory } ") ;
12
14
13
15
// TEST PROJECTS:
14
16
//
15
17
// Test projects are generated from the main multi-targeted test project:
16
- // "Lambda2Js .Tests.csproj" file.
18
+ // "{ProjectName} .Tests.csproj" file.
17
19
18
20
{
19
21
20
22
var l2jsTests = new XmlDocument ( ) ;
21
- l2jsTests . Load ( "../Lambda2Js .Tests/Lambda2Js .Tests.csproj" ) ;
23
+ l2jsTests . Load ( $ "../{ ProjectName } .Tests/{ ProjectName } .Tests.csproj") ;
22
24
23
25
var targetsElement = l2jsTests . SelectNodes ( "//TargetFrameworks" ) ;
24
26
Console . WriteLine ( targetsElement [ 0 ] . InnerText ) ;
25
27
var targets = targetsElement [ 0 ] . InnerText . Split ( ";" ) ;
26
28
foreach ( var target in targets )
27
29
{
28
- if ( File . Exists ( $ "../Lambda2Js .Tests/Lambda2Js .Tests.{ target } .csproj") )
30
+ if ( File . Exists ( $ "../{ ProjectName } .Tests/{ ProjectName } .Tests.{ target } .csproj") )
29
31
continue ;
30
32
31
33
var l2jsTestNew = ( XmlDocument ) l2jsTests . Clone ( ) ;
32
34
var node = l2jsTestNew . SelectSingleNode ( "//TargetFrameworks" ) ;
33
35
var targetElement = l2jsTestNew . CreateElement ( "TargetFramework" ) ;
34
36
targetElement . InnerText = target ;
35
37
node . ParentNode . ReplaceChild ( targetElement , node ) ;
36
- l2jsTestNew . Save ( $ "../Lambda2Js .Tests/Lambda2Js .Tests.{ target } .csproj") ;
38
+ l2jsTestNew . Save ( $ "../{ ProjectName } .Tests/{ ProjectName } .Tests.{ target } .csproj") ;
37
39
}
38
40
39
41
}
40
42
41
43
// SIGNED ASSEMBLY
42
44
//
43
- // Signed assembly is generated from the main "Lambda2Js .csproj" file.
45
+ // Signed assembly is generated from the main "{ProjectName} .csproj" file.
44
46
45
47
{
46
48
47
49
var l2js = new XmlDocument ( ) ;
48
- l2js . Load ( "../Lambda2Js/Lambda2Js .csproj" ) ;
50
+ l2js . Load ( $ "../{ ProjectName } / { ProjectName } .csproj") ;
49
51
50
52
var sig = ( XmlDocument ) l2js . Clone ( ) ;
51
53
var sigMain = sig . SelectSingleNode ( "//TargetFrameworks" ) . ParentNode ;
52
54
var ver = sigMain . SelectSingleNode ( "Version" ) . InnerText ;
53
55
54
56
sigMain . SelectSingleNode ( "AssemblyVersion" ) . InnerText = $ "{ ver } .0";
55
57
sigMain . SelectSingleNode ( "FileVersion" ) . InnerText = $ "{ ver } .0";
56
- sigMain . SelectSingleNode ( "PackageId" ) . InnerText = "Lambda2Js .Signed" ;
58
+ sigMain . SelectSingleNode ( "PackageId" ) . InnerText + = ".Signed" ;
57
59
sigMain . AppendChild ( sig . CreateElement ( "SignAssembly" ) . With ( x => x . InnerText = "true" ) ) ;
58
- sigMain . AppendChild ( sig . CreateElement ( "AssemblyOriginatorKeyFile" ) . With ( x => x . InnerText = @"..\Lambda2Js.snk" ) ) ;
59
- sigMain . AppendChild ( sig . CreateElement ( "RootNamespace" ) . With ( x => x . InnerText = "Lambda2Js" ) ) ;
60
- sigMain . AppendChild ( sig . CreateElement ( "AssemblyName" ) . With ( x => x . InnerText = "Lambda2Js.Signed" ) ) ;
60
+ sigMain . AppendChild ( sig . CreateElement ( "AssemblyOriginatorKeyFile" ) . With ( x => x . InnerText = $@ "..\{ ProjectName } .snk") ) ;
61
+
62
+ if ( sigMain . SelectSingleNode ( "RootNamespace" ) == null )
63
+ sigMain . AppendChild ( sig . CreateElement ( "RootNamespace" ) . With ( x => x . InnerText = $ "{ ProjectName } ") ) ;
61
64
62
- foreach ( XmlNode doc in sig . SelectNodes ( "DocumentationFile" ) )
63
- doc . InnerText = doc . InnerText . Replace ( "Lambda2Js.xml" , "Lambda2Js.Signed.xml" ) ;
65
+ if ( sigMain . SelectSingleNode ( "AssemblyName" ) == null )
66
+ sigMain . AppendChild ( sig . CreateElement ( "AssemblyName" ) . With ( x => x . InnerText = $ "{ ProjectName } .Signed") ) ;
67
+ else
68
+ sigMain . SelectSingleNode ( "AssemblyName" ) . InnerText += ".Signed" ;
64
69
65
- sig . Save ( $ "../Lambda2Js/Lambda2Js.Signed.csproj") ;
70
+ foreach ( XmlNode doc in sig . SelectNodes ( "//DocumentationFile" ) )
71
+ doc . InnerText = doc . InnerText . Replace ( $ "{ ProjectName } .xml", $ "{ ProjectName } .Signed.xml") ;
72
+
73
+ sig . Save ( $ "../{ ProjectName } /{ ProjectName } .Signed.csproj") ;
66
74
67
75
}
68
76
69
- Console . WriteLine ( "Hello World! " ) ;
77
+ Console . WriteLine ( "Press any key to exit " ) ;
70
78
Console . ReadKey ( ) ;
71
79
}
72
80
}
81
+
73
82
static class ObjectExtensions
74
83
{
75
84
public static T With < T > ( this T obj , Action < T > action )
0 commit comments