如何使用dotnet-cli/vscode将清单文件添加到c#?

发布于 2025-01-30 19:26:30 字数 161 浏览 2 评论 0原文

我正在尝试将清单文件添加到我的C#项目中,但是我发现的所有答案/解决方案都应该右键单击Visual Studio中的C#项目。我使用Visual Studio代码,因此我无法真正这样做。有人有解决方案吗?

我需要清单文件来索取运行时的管理权。我找到了很多答案,我唯一的问题是我无法添加清单文件。

I'm trying to add a manifest file to my C# project, but all the answers/solutions I find say that I should right click on the C# project in Visual Studio. I use Visual Studio Code so I can't really do that. does anyone have a solution?

I need the manifest file to ask for admin rights on runtime. I found a lot of answers to that, my only problem is that I can't add a manifest file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末 2025-02-06 19:26:30

我遇到了同样的问题-hth;):

  1. 在您的.csproj文件的同一目录上单击“新文件...”

  2. 将您的文件命名为:app.manifest

  3. 在下面复制代码(默认app.manifest content)中的文件:

     <?xml版本=“ 1.0” encoding =“ utf-8”?>
    < assembly subtestversion =“ 1.0” xmlns =“ urn:schemas-microsoft-com:asm.v1”>
      < assemblyIdentity版本=“ 1.0.0.0” name =“ myApplication.app”/>
      < trustInfo xmlns =“ urn:schemas-microsoft-com:asm.v2”>
        < security>
          < requestedPrivileges xmlns =“ urn:schemas-microsoft-com:asm.v3”>
            <! -  UAC清单选项
                 如果要更改Windows用户帐户控制级别替换 
                 请求executionLevel节点,其中一个。
    
            < requestEdexecutionLevel级别=“ asinvoker” uiaccess =“ false” />
            < requestEdexecutionLevel lats =“ sighteadMinistrator” uiaccess =“ false” />
            < requestEdexecutionLevel lats =“ distableable” uiaccess =“ false” />
    
                指定请求的ExecutionLevel元素将禁用文件和注册表虚拟化。 
                如果您的应用程序需要此虚拟化,请删除此元素
                兼容性。
             - >
            < requestEdexecutionLevel级别=“ asinvoker” uiaccess =“ false” />
          </requestedPrivileges>
        </security>
      </trustinfo>
    
      <兼容性xmlns =“ urn:schemas-microsoft-com:compatible.v1”>
        < application>
          <! - 该应用程序已在已测试的Windows版本列表中
               被设计为合作。删除适当的元素和窗口将 
               自动选择最兼容的环境。 - >
    
          <! -  Windows Vista  - >
          <! - < supportedos ID =“ {e2111457-1546-43c5-a5fe-008deeee3d3f0}” />  - >
    
          <! -  Windows 7->
          <! - < supportEdos ID =“ {35138B9A-5D96-4FBD-8E2D-A2440225F93A}” {35138B9A-5D96-4FBD-8E2D-A2444025F93A}” />  - >
    
          <! -  Windows 8->
          <! - < supportedos ID =“ {4A2F28E3-53B9-4441-BA9C-D69D4A4A4A6E6E38}” />  - >
    
          <! -  Windows 8.1  - >
          <! - < supportedos ID =“ {1F676C76-80E1-4239-95BB-83D0F6D0DA78}” />  - >
    
          <! -  Windows 10  - >
          <! - < supportedos ID =“ {8E0F7A12-BFB3-4FE8-B9A5-48FD50A15A9A}” />  - >
    
        </application>
      </兼容性>
    
      !
           DPI。 Windows演示基金会(WPF)应用程序会自动了解,不需要 
           选择。Windows表单应用程序针对.NET框架4.6选择进入此设置,应 
           还将“ enableWindowsFormShighDpiautoresized”设置设置为他们的app.config中的“ true”。 - >
      <! - 
      <应用程序xmlns =“ urn:schemas-microsoft-com:asm.v3”>
        < WindowsSettings>
          < dpiaware xmlns =“ http://schemas.microsoft.com/smi/2005/windowssetsettings”> true</dpiaware>
        </windowsSettings>
      </application>
       - >
    
      <! - 启用Windows Common控件和对话框的主题(Windows XP和以后) - >
      <! - 
      <依赖关系>
        <依赖设备>
          <组装官员
              type =“ win32”
              名称=“ Microsoft.windows.common-Controls”
              版本=“ 6.0.0.0”
              processorarchitecture =“*”
              publicKeyToken =“ 6595B64144CCF1DF”
              语言=“*”
            />
        </depententSembly>
      </depentency>
       - >
    
    </insembly>
     
  4. 现在您可以编辑它;如默认文件中所述,您可以使用三个级别来requesteDexecutionLevel标签EG:

     < requestEdexecutionLevel latve =“ sighteadMinistrator” uiaccess =“ false” />
     
  5. 保存后,您应该通过将下面的标签添加到.csproj 在第一个propertyGroup标签下的任何位置的文件:

     < propertyGroup>
        < applicationManifest> app.manifest</applicationManifest>
      </propertyGroup>
     

I had a same issue -HTH ;):

  1. At the same directory of your .csproj file click on "New File..."

  2. Name your file to: app.manifest

  3. Copy below code (The default app.manifest content) in it:

    <?xml version="1.0" encoding="utf-8"?>
    <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
      <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
          <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
            <!-- UAC Manifest Options
                 If you want to change the Windows User Account Control level replace the 
                 requestedExecutionLevel node with one of the following.
    
            <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
            <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
            <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
    
                Specifying requestedExecutionLevel element will disable file and registry virtualization. 
                Remove this element if your application requires this virtualization for backwards
                compatibility.
            -->
            <requestedExecutionLevel level="asInvoker" uiAccess="false" />
          </requestedPrivileges>
        </security>
      </trustInfo>
    
      <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
          <!-- A list of the Windows versions that this application has been tested on and is
               is designed to work with. Uncomment the appropriate elements and Windows will 
               automatically selected the most compatible environment. -->
    
          <!-- Windows Vista -->
          <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
    
          <!-- Windows 7 -->
          <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
    
          <!-- Windows 8 -->
          <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
    
          <!-- Windows 8.1 -->
          <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
    
          <!-- Windows 10 -->
          <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
    
        </application>
      </compatibility>
    
      <!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
           DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need 
           to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should 
           also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
      <!--
      <application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings>
          <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
        </windowsSettings>
      </application>
      -->
    
      <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
      <!--
      <dependency>
        <dependentAssembly>
          <assemblyIdentity
              type="win32"
              name="Microsoft.Windows.Common-Controls"
              version="6.0.0.0"
              processorArchitecture="*"
              publicKeyToken="6595b64144ccf1df"
              language="*"
            />
        </dependentAssembly>
      </dependency>
      -->
    
    </assembly>
    
  4. Now you can edit it; As commented in the default file you can use three levels for requestedExecutionLevel tag e.g.:

    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
    
  5. After saving that, you should add it to your project by adding below tag to your .csproj file anywhere under first PropertyGroup tag:

      <PropertyGroup>
        <ApplicationManifest>app.manifest</ApplicationManifest>
      </PropertyGroup>
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文