@@ -36,8 +36,7 @@ public CodeGenTests(ITestOutputHelper logger)
3636 var workspace = new AdhocWorkspace ( ) ;
3737 var project = workspace . CurrentSolution . AddProject ( "test" , "test" , "C#" )
3838 . WithCompilationOptions ( new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) )
39- . AddMetadataReferences ( GetReferences ( "Profile78" ) )
40- . AddMetadataReference ( MetadataReference . CreateFromFile ( Assembly . Load ( "netstandard, Version=2.0.0.0" ) . Location ) )
39+ . AddMetadataReferences ( GetNetStandard20References ( ) )
4140 . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( GenerateImmutableAttribute ) . Assembly . Location ) )
4241 . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( CodeGenerationAttributeAttribute ) . Assembly . Location ) )
4342 . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Optional ) . Assembly . Location ) )
@@ -337,10 +336,11 @@ private static string EscapeLineEndingCharacters(string whitespace)
337336 return builder . ToString ( ) ;
338337 }
339338
340- private static IEnumerable < MetadataReference > GetReferences ( string profile )
339+ private static IEnumerable < MetadataReference > GetNetStandard20References ( )
341340 {
342- string profileDirectory = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFilesX86 ) , @"Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile" , profile ) ;
343- foreach ( string assembly in Directory . GetFiles ( profileDirectory , "*.dll" ) )
341+ string nugetPackageRoot = Environment . GetEnvironmentVariable ( "NUGET_PACKAGES" ) ?? Environment . ExpandEnvironmentVariables ( @"%USERPROFILE%\.nuget\packages" ) ;
342+ string netstandardRoot = Path . Combine ( nugetPackageRoot , @"netstandard.library\2.0.3\build\netstandard2.0\ref" ) ;
343+ foreach ( string assembly in Directory . GetFiles ( netstandardRoot , "*.dll" ) )
344344 {
345345 yield return MetadataReference . CreateFromFile ( assembly ) ;
346346 }
0 commit comments