我需要根据所选的构建配置从launchSettings.json中选择配置文件。可以说我已经建立了Debug,Debug-2和config配置文件,我需要从launchSettings.json中为每个文件选择不同的配置文件。有办法吗?
答案 0 :(得分:0)
我使用“复制”MSBuild 任务在构建过程中使用 Debug 或 Release 版本覆盖 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>