@@ -11,7 +11,9 @@ import * as jsonc from 'jsonc-parser';
1111
1212import { AssetGenerator , ProgramLaunchType , replaceCommentPropertiesWithComments , updateJsonWithComments } from '../../src/assets' ;
1313import { parse } from 'jsonc-parser' ;
14- import { should } from 'chai' ;
14+ import { use as chaiUse , should } from 'chai' ;
15+
16+ chaiUse ( require ( 'chai-string' ) ) ;
1517
1618suite ( "Asset generation: csproj" , ( ) => {
1719 suiteSetup ( ( ) => should ( ) ) ;
@@ -96,11 +98,9 @@ suite("Asset generation: csproj", () => {
9698 let generator = new AssetGenerator ( info , createMockWorkspaceFolder ( rootPath ) ) ;
9799 generator . setStartupProject ( 0 ) ;
98100 let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Console ) , undefined , { disallowComments : true } ) ;
99- let programPath = launchJson [ 0 ] . program ;
101+ let programPath : string = launchJson [ 0 ] . program ;
100102
101- // ${workspaceFolder}/bin/Debug/netcoreapp1.0/testApp.dll
102- let segments = programPath . split ( path . posix . sep ) ;
103- segments . should . deep . equal ( [ '${workspaceFolder}' , 'bin' , 'Debug' , 'netcoreapp1.0' , 'testApp.dll' ] ) ;
103+ checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
104104 } ) ;
105105
106106 [ 5 , 6 , 7 , 8 , 9 ] . forEach ( version => {
@@ -112,11 +112,9 @@ suite("Asset generation: csproj", () => {
112112 let generator = new AssetGenerator ( info , createMockWorkspaceFolder ( rootPath ) ) ;
113113 generator . setStartupProject ( 0 ) ;
114114 let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Console ) , undefined , { disallowComments : true } ) ;
115- let programPath = launchJson [ 0 ] . program ;
115+ let programPath : string = launchJson [ 0 ] . program ;
116116
117- // ${workspaceFolder}/bin/Debug/net#.0/testApp.dll
118- let segments = programPath . split ( path . posix . sep ) ;
119- segments . should . deep . equal ( [ '${workspaceFolder}' , 'bin' , 'Debug' , shortName , 'testApp.dll' ] ) ;
117+ checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
120118 } ) ;
121119 } ) ;
122120
@@ -126,11 +124,9 @@ suite("Asset generation: csproj", () => {
126124 let generator = new AssetGenerator ( info , createMockWorkspaceFolder ( rootPath ) ) ;
127125 generator . setStartupProject ( 0 ) ;
128126 let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Console ) , undefined , { disallowComments : true } ) ;
129- let programPath = launchJson [ 0 ] . program ;
127+ let programPath : string = launchJson [ 0 ] . program ;
130128
131- // ${workspaceFolder}/nested/bin/Debug/netcoreapp1.0/testApp.dll
132- let segments = programPath . split ( path . posix . sep ) ;
133- segments . should . deep . equal ( [ '${workspaceFolder}' , 'nested' , 'bin' , 'Debug' , 'netcoreapp1.0' , 'testApp.dll' ] ) ;
129+ checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
134130 } ) ;
135131
136132 test ( "Create launch.json for Blazor web assembly standalone project opened in workspace" , ( ) => {
@@ -164,12 +160,12 @@ suite("Asset generation: csproj", () => {
164160 generator . setStartupProject ( 0 ) ;
165161 const launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . BlazorWebAssemblyHosted ) , undefined , { disallowComments : true } ) ;
166162 const hostedBlazorLaunchConfig = launchJson [ 0 ] ;
167- const programPath = hostedBlazorLaunchConfig . program ;
163+ const programPath : string = hostedBlazorLaunchConfig . program ;
168164 const cwd = hostedBlazorLaunchConfig . cwd ;
169165 const hosted = hostedBlazorLaunchConfig . hosted ;
170166
171- let segments = programPath . split ( path . posix . sep ) ;
172- segments . should . deep . equal ( [ '${workspaceFolder}' , 'bin' , 'Debug' , 'netcoreapp3.0' , 'testApp.dll' ] ) ;
167+ checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
168+
173169 cwd . should . equal ( '${workspaceFolder}' ) ;
174170 hosted . should . equal ( true ) ;
175171 } ) ;
@@ -181,12 +177,12 @@ suite("Asset generation: csproj", () => {
181177 generator . setStartupProject ( 0 ) ;
182178 let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . BlazorWebAssemblyHosted ) , undefined , { disallowComments : true } ) ;
183179 const hostedBlazorLaunchConfig = launchJson [ 0 ] ;
184- const programPath = hostedBlazorLaunchConfig . program ;
180+ const programPath : string = hostedBlazorLaunchConfig . program ;
185181 const cwd = hostedBlazorLaunchConfig . cwd ;
186182 const hosted = hostedBlazorLaunchConfig . hosted ;
187183
188- let segments = programPath . split ( path . posix . sep ) ;
189- segments . should . deep . equal ( [ '${workspaceFolder}' , 'nested' , 'bin' , 'Debug' , 'netcoreapp3.0' , 'testApp.dll' ] ) ;
184+ checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
185+
190186 cwd . should . equal ( '${workspaceFolder}/nested' ) ;
191187 hosted . should . equal ( true ) ;
192188 } ) ;
@@ -197,11 +193,9 @@ suite("Asset generation: csproj", () => {
197193 let generator = new AssetGenerator ( info , createMockWorkspaceFolder ( rootPath ) ) ;
198194 generator . setStartupProject ( 0 ) ;
199195 let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Web ) , undefined , { disallowComments : true } ) ;
200- let programPath = launchJson [ 0 ] . program ;
196+ let programPath : string = launchJson [ 0 ] . program ;
201197
202- // ${workspaceFolder}/bin/Debug/netcoreapp1.0/testApp.dll
203- let segments = programPath . split ( path . posix . sep ) ;
204- segments . should . deep . equal ( [ '${workspaceFolder}' , 'bin' , 'Debug' , 'netcoreapp1.0' , 'testApp.dll' ] ) ;
198+ checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
205199 } ) ;
206200
207201 test ( "Create launch.json for nested web project opened in workspace" , ( ) => {
@@ -210,11 +204,9 @@ suite("Asset generation: csproj", () => {
210204 let generator = new AssetGenerator ( info , createMockWorkspaceFolder ( rootPath ) ) ;
211205 generator . setStartupProject ( 0 ) ;
212206 let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Web ) , undefined , { disallowComments : true } ) ;
213- let programPath = launchJson [ 0 ] . program ;
207+ let programPath : string = launchJson [ 0 ] . program ;
214208
215- // ${workspaceFolder}/nested/bin/Debug/netcoreapp1.0/testApp.dll
216- let segments = programPath . split ( path . posix . sep ) ;
217- segments . should . deep . equal ( [ '${workspaceFolder}' , 'nested' , 'bin' , 'Debug' , 'netcoreapp1.0' , 'testApp.dll' ] ) ;
209+ checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
218210 } ) ;
219211
220212 test ( "Add a new item to JSON" , ( ) => {
@@ -316,6 +308,11 @@ suite("Asset generation: csproj", () => {
316308 } ) ;
317309} ) ;
318310
311+ function checkProgramPath ( rootPath : string , programPath : string , targetPath : string ) : void {
312+ programPath . should . startWith ( '${workspaceFolder}/' ) ;
313+ programPath . should . equal ( targetPath . replace ( rootPath , '${workspaceFolder}' ) . replaceAll ( path . win32 . sep , path . posix . sep ) ) ;
314+ }
315+
319316function createMockWorkspaceFolder ( rootPath : string ) : vscode . WorkspaceFolder {
320317 return {
321318 uri : vscode . Uri . file ( rootPath ) ,
@@ -333,7 +330,7 @@ function createMSBuildWorkspaceInformation(projectPath: string, assemblyName: st
333330 ProjectGuid : '' ,
334331 Path : projectPath ,
335332 AssemblyName : assemblyName ,
336- TargetPath : path . join ( path . dirname ( projectPath ) , 'bin' , 'Debug' , targetFrameworkShortName , `${ assemblyName } .dll` ) ,
333+ TargetPath : path . join ( path . dirname ( projectPath ) , 'bin' , 'Debug' , new Date ( ) . getTime ( ) . toString ( ) , targetFrameworkShortName , `${ assemblyName } .dll` ) ,
337334 TargetFramework : '' ,
338335 SourceFiles : [ ] ,
339336 TargetFrameworks : [
0 commit comments