sln2csproj 0.2.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/README.md CHANGED
@@ -262,12 +262,15 @@ git tag v0.2.0
262
262
  git push origin v0.2.0
263
263
  ```
264
264
 
265
- The workflow will:
265
+ The workflow will always:
266
266
 
267
267
  - install dependencies
268
268
  - run tests
269
- - publish the npm package
270
269
  - build a Windows `exe`
271
- - attach the Windows `exe` and `.zip` to the GitHub Release when triggered by a version tag
270
+
271
+ When triggered by a version tag such as `v0.3.0`, it will also:
272
+
273
+ - publish the npm package
274
+ - attach the Windows `exe` and `.zip` to the GitHub Release
272
275
 
273
276
  The Windows executable is built with Node.js Single Executable Applications (SEA), so Windows users can download it from GitHub Releases without installing Node first.
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: 例如 "..\\..\\..\\HCT.WebSite"
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 references = Array.from(hintByDll.entries()).map(([dllName, hintPath]) => {
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
- <!-- ⚠️ 此檔案由 sln2csproj 自動產生 -->
77
- <!-- ⚠️ 僅供 IntelliSense 使用,請勿拿來 build -->
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sln2csproj",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Generate a fake csproj for legacy ASP.NET WebSite projects in a .sln.",
5
5
  "type": "commonjs",
6
6
  "bin": {