Conditionally embedding a resource in Visual Studio (C#)

你离开我真会死。 提交于 2019-12-03 01:51:11

This did the trick. You can edit your csproj by right clicking in Visual Studio on the project and selecting "edit".

  <Choose>
    <When Condition=" '$(Configuration)'!='ReleaseExternal' And '$(Platform)'=='x86' ">
      <ItemGroup>
        <EmbeddedResource Include="file.dll">
          <Link>Resources\Other\file.dll</Link>
        </EmbeddedResource>
      </ItemGroup>
    </When>
  </Choose>

You can conditionally embed the resource in your csproj-file depending on configuration, however I'm not sure if you're able to control it using #if statements in your code.

Maybe add a custom build-configuration instead (in addition to "Debug" and "Release")? And then just manually edit your csproj-file to embed it if $(Configuration == 'your custom buildconf').

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!