.net - Temporarily change manifest requestedExecutionLevel when debugging -
i'm developing application in visual studio require administrator permissions after installed on user's system. i've added proper application manifest file make sure happens:
<requestedexecutionlevel level="requireadministrator" uiaccess="false" />
however if want debug program in visual studio, required run visual studio administrator. no bueno. , annoying part program doesn't need administrator privileges during debugging. requires privileges after being installed on user's system.
is there clean, easy way "throw switch" disables administrator requirement during development, , re-enables when release application?
edit:
when release application user, run build script uses msbuild. i'm trying make visual studio build solution in release configuration without administrator manifest. when run build script, want msbuild include administrator manifest while keeping same release configuration.
you can pre-build events project -> options -> build events
make pre-build event :
del "$(projectdir)app.manifest" if "$(configurationname)"=="debug" ( copy "$(projectdir)app.debug.manifest" "$(projectdir)app.manifest" ) else ( copy "$(projectdir)app.release.manifest" "$(projectdir)app.manifest" )
here we're assuming manifest called app.manifest
, in root directory project - modify needed.
in case, make 2 copies of manifest file , call 1 app.debug.manifest
, 1 app.release.manifest
, configure them appropriately, , replace active app.manifest
appropriate version before each build.
edit:
if want msbuild use same configuration different manifest visual studio, may try tweaking above pre-build event this:
del "$(projectdir)app.manifest" if "$(adminmanifest)"=="true" ( copy "$(projectdir)app.release.manifest" "$(projectdir)app.manifest" ) else ( copy "$(projectdir)app.debug.manifest" "$(projectdir)app.manifest" )
now when run msbuild, can so:
msbuild.exe mysolution.sln /p:configuration=whateveryouwant /p:adminmanifest=true
see :
Comments
Post a Comment