'How to request administrator permissons only on release builds?
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>
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lucas |
