Description: I want my application to request administrator permissions only when it is compiled using my Release configuration. The main reason for it is that I do not need the administrator permission when debugging/developing the app, but it requires administrator permission when delivered.
Currently I only use the app.manifest file for requesting the administrator permissions with the following code:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Now to my question: Where in my project file (name.csproj) do I have to include the app.manifest file in order to only embed it when I'm using my "Release" configuration?
I use the following code to include the app.manifest file inside the project file:
<ApplicationManifest>app.manifest</ApplicationManifest>
CodePudding user response:
After taking another look at my project file I figured out where to put it.
Answer: Inside the following PropertyGroup in the project file (name.csproj), which represents the "Release" build,
you have to put the following code to include the app.manifest file:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
...
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
This allows to only request administrator rights on "Release" builds. It can also be added on other build configurations as well.