![](/img/trans.png)
[英]Can a profile from the launchSettings.json file be loaded when running unit tests?
[英]Choose launchSettings.json profile based on build configuration
我需要根据选择的构建配置从 launchSettings.json 中选择配置文件。 假设我已经构建了 Debug、Debug-2 配置,我需要从 launchSettings.json 中为它们中的每一个选择不同的配置文件。 有没有办法做到这一点?
我使用“复制”MSBuild 任务在构建期间使用调试或发布版本覆盖 launchSettings.json:
<ItemGroup>
<UpToDateCheckInput Include="Properties/launchSettings.$(Configuration).json" />
</ItemGroup>
<Target Name="CleanLaunchSettings" AfterTargets="Clean">
<Message Importance="high" Text="Deleting launchSettings.json..." />
<Delete Files="Properties/launchSettings.json" />
</Target>
<Target Name="CopyLaunchSettings" AfterTargets="Build" Inputs="Properties/launchSettings.$(Configuration).json" Outputs="Properties/launchSettings.json">
<Message Importance="high" Text="Copying launchSettings.$(Configuration).json..." />
<Copy SourceFiles="Properties/launchSettings.$(Configuration).json" DestinationFiles="Properties/launchSettings.json" />
</Target>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.