sln2csproj 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +5 -0
- package/bin/generator.js +24 -6
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -158,6 +158,11 @@ function main() {
|
|
|
158
158
|
(0, io_1.mkdirp)(fakeDirAbs);
|
|
159
159
|
const websiteAbs = path.join(slnDir, website.physicalPath);
|
|
160
160
|
const websiteRelFromFake = path.relative(fakeDirAbs, websiteAbs).replace(/\//g, '\\') || '.';
|
|
161
|
+
for (const ref of website.projectReferences) {
|
|
162
|
+
if (!ref.projectPath)
|
|
163
|
+
continue;
|
|
164
|
+
ref.projectPath = path.relative(fakeDirAbs, path.resolve(slnDir, ref.projectPath)).replace(/\//g, '\\') || '.';
|
|
165
|
+
}
|
|
161
166
|
const mode = opt.mode || 'copy';
|
|
162
167
|
const refsDirAbs = path.join(fakeDirAbs, 'refs');
|
|
163
168
|
const hintByDll = (0, resolver_1.materializeRefs)(mode, fakeDirAbs, refsDirAbs, websiteAbs, websiteRelFromFake, website);
|
package/bin/generator.js
CHANGED
|
@@ -44,7 +44,7 @@ function esc(s) {
|
|
|
44
44
|
.replace(/'/g, ''');
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* websiteRelFromFake:
|
|
47
|
+
* websiteRelFromFake: e.g. "..\\..\\..\\HCT.WebSite"
|
|
48
48
|
* hintByDll: dllName -> HintPath (relative to fake project dir)
|
|
49
49
|
*/
|
|
50
50
|
function generateFakeCsproj(website, websiteRelFromFake, hintByDll) {
|
|
@@ -64,7 +64,23 @@ function generateFakeCsproj(website, websiteRelFromFake, hintByDll) {
|
|
|
64
64
|
const inc = esc(path.join(prefix, '**', `*.${ext}`)).replace(/\//g, '\\');
|
|
65
65
|
return ` <Content Include="${inc}" />`;
|
|
66
66
|
}).join('\n');
|
|
67
|
-
const
|
|
67
|
+
const projectReferences = website.projectReferences
|
|
68
|
+
.filter(ref => ref.projectPath)
|
|
69
|
+
.map(ref => {
|
|
70
|
+
const include = esc(ref.projectPath || '');
|
|
71
|
+
const projectGuid = esc(ref.guid.toUpperCase());
|
|
72
|
+
const projectName = esc(path.basename(ref.projectPath || '', path.extname(ref.projectPath || '')));
|
|
73
|
+
return ` <ProjectReference Include="${include}">
|
|
74
|
+
<Project>{${projectGuid}}</Project>
|
|
75
|
+
<Name>${projectName}</Name>
|
|
76
|
+
</ProjectReference>`;
|
|
77
|
+
}).join('\n');
|
|
78
|
+
const projectDllNames = new Set(website.projectReferences
|
|
79
|
+
.filter(ref => ref.projectPath)
|
|
80
|
+
.map(ref => ref.dllName.toLowerCase()));
|
|
81
|
+
const references = Array.from(hintByDll.entries())
|
|
82
|
+
.filter(([dllName]) => !projectDllNames.has(dllName.toLowerCase()))
|
|
83
|
+
.map(([dllName, hintPath]) => {
|
|
68
84
|
const includeName = esc(dllName.replace(/\.dll$/i, ''));
|
|
69
85
|
const hint = esc(hintPath || path.join(prefix, 'Bin', dllName)).replace(/\//g, '\\');
|
|
70
86
|
return ` <Reference Include="${includeName}">
|
|
@@ -73,8 +89,8 @@ function generateFakeCsproj(website, websiteRelFromFake, hintByDll) {
|
|
|
73
89
|
</Reference>`;
|
|
74
90
|
}).join('\n');
|
|
75
91
|
return `<?xml version="1.0" encoding="utf-8"?>
|
|
76
|
-
<!--
|
|
77
|
-
<!--
|
|
92
|
+
<!-- Generated by sln2csproj -->
|
|
93
|
+
<!-- IntelliSense only; do not use for real builds -->
|
|
78
94
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
79
95
|
<PropertyGroup>
|
|
80
96
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
@@ -87,7 +103,6 @@ function generateFakeCsproj(website, websiteRelFromFake, hintByDll) {
|
|
|
87
103
|
</PropertyGroup>
|
|
88
104
|
|
|
89
105
|
<ItemGroup>
|
|
90
|
-
<!-- 基本 Framework refs -->
|
|
91
106
|
<Reference Include="System" />
|
|
92
107
|
<Reference Include="System.Data" />
|
|
93
108
|
<Reference Include="System.Drawing" />
|
|
@@ -98,10 +113,13 @@ function generateFakeCsproj(website, websiteRelFromFake, hintByDll) {
|
|
|
98
113
|
<Reference Include="System.Configuration" />
|
|
99
114
|
<Reference Include="System.Xml.Linq" />
|
|
100
115
|
|
|
101
|
-
<!-- 從 sln 解析出的 refs -->
|
|
102
116
|
${references}
|
|
103
117
|
</ItemGroup>
|
|
104
118
|
|
|
119
|
+
<ItemGroup>
|
|
120
|
+
${projectReferences}
|
|
121
|
+
</ItemGroup>
|
|
122
|
+
|
|
105
123
|
<ItemGroup>
|
|
106
124
|
<Compile Include="${compileInclude}" Exclude="${esc(compileExclude)}" />
|
|
107
125
|
</ItemGroup>
|