Skip to content

Commit

Permalink
Fix the issue in unit tests.
Browse files Browse the repository at this point in the history
- In the module we create a minimum runspace for PowerShell, and use it to parse the command line.
  The mini runspace contains the built-in core modules for PowerShell. We don't need them when we
  package and publish our module because the runtime will have them. That'll reduce the module size.
  So in the module project we exclude `contentfiles` when we referece Microsoft.PowerShell.SDK.
- The issue in the unit tests is that it doesn't find the built-in core module when we create the runspace.
  So we have a reference to Microsoft.PowerShell.SDK in the test project to include `contentfiles` to provide
  the built-in core modules. The unit tests can run successfully.
  • Loading branch information
kceiw committed May 25, 2022
1 parent 044b566 commit c921a7e
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\Az.Tools.Predictor\Az.Tools.Predictor.csproj" />
<!-- The test project doesn't reference to it directly. Az.Tools.Predictor has a reference to Microsoft.PowerShell.SDK.
- But it's excluding content files to reduce the size of the module. The content files are not needed since they're in the runtime (PowerShell)
- The content files are needed to set up the runspace to parse the command line. So we need to include them when we run the unit tests.
-->
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit c921a7e

Please sign in to comment.