gpt4 book ai didi

visual-studio-2010 - 如何在 Visual Studio 2013 中禁用调试版本的代码签名?

转载 作者:行者123 更新时间:2023-12-03 22:25:44 26 4
gpt4 key购买 nike

我们最近将 Visual Studio 从 2010 年升级到 2013 年,除了一件事之外,一切似乎都和以前一样。 2010 年代码签名只在发布项目时执行,但在 2013 年它想在我们每次构建项目时对输出程序集进行签名。

我在尝试在线查找有关此问题的任何结果时遇到问题,一切都只指向如何设置签名,而不是如何在正常调试版本期间阻止它签名。

我创建了一个新项目并开始使用设置来确定在正常构建期间可能触发签名要求的单个设置。在“安全”选项卡下的项目属性页面中,如果选中“启用 ClickOnce 安全设置”复选框,则 2013 年需要签名步骤,但 2010 年似乎没有该要求。

我仍然需要确认这是否是这种行为的唯一决策点。

确认的。

我创建了两个解决方案,每个解决方案都有一个空的 WinForms 应用程序。一个解决方案是在 Visual Studio 2010 中创建的,另一个是在 Visual Studio 2013 中创建的。我进入了每个项目的属性并通过签名选项卡启用了签名,然后在安全选项卡中用“This是一个完全信任的应用程序”。请注意,项目正在使用启用 PIN 的智能卡上的证书进行签名。

VS 2013 在 Debug模式下的正常构建过程中会提示输入智能卡 PIN,而 2010 不会。现在的问题基本上是为什么两个版本之间存在差异,以及如何在 2013 年解决这个问题以使其表现得像 2010 年一样。

我包含了我在下面创建的测试解决方案的项目文件。比较差异并不指向任何明显不同的地方。我还尝试将 VS 2013 项目更改为针对与 VS 2010 项目相同的框架,以最小化项目之间的差异 - 这不会改变行为差异。

Visual Studio 2010 项目文件

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E31DA60C-E444-4E34-AF6D-5B4588CC1F8E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SigningTest1</RootNamespace>
<AssemblyName>SigningTest1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>22E252B5076264F4F2CD88983A9053D554CCD185</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Visual Studio 2013 项目文件

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{732A657C-452D-4942-8832-89A14314739C}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SigningTest2013</RootNamespace>
<AssemblyName>SigningTest2013</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>22E252B5076264F4F2CD88983A9053D554CCD185</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

我会尽量上传一个完整的解决方案。由于大多数文件共享网站被阻止,我无法在我当前的计算机上执行此操作。

最佳答案

这篇文章包含迄今为止为行为改变找到的最佳解决方案。解决方案是由 Leandro Taset 提出的在 comment to the original question :

对于需要代码签名的项目,打开其关联的.csproj文件。您应该可以找到 SignManifests PropertyGroup 内的节点该文件中列出的节点如下所示:

<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>

此属性显示在 VS2010 和 VS2013 项目文件中,并列在项目范围内。您应该能够找到两个不同的 Property Group类似于以下内容的节点:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<!-- There may be several properties already in the PropertyGroup node -->
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<!-- There may be several properties already in the PropertyGroup node -->
</PropertyGroup>

这些 PropertyGroup节点定义了项目属性,这些属性根据构建项目时的当前配置和目标平台有条件地应用。

您需要删除 SignManifests您首先找到的节点并放置一个新的 SignManifests每个条件中的节点 PropertyGroup节点:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<!-- -->
<SignManifests>false</SignManifests>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<!-- -->
<SignManifests>true</SignManifests>
</PropertyGroup>

这将导致 VS2013 表现得更好一点。在发布版本期间(好吧,在针对 AnyCPU 的发布版本示例中),VS2013 将尝试对 list 进行签名,而在 Debug模式下则不会。

此解决方案的几个警告:
  • 这并不是启用 ClickOnce 签名时 VS2010 的行为方式。 VS2010 只会在 ClickOnce 发布期间签名,不会在构建期间签名(无论配置和目标平台如何)。
  • 如果您在 VS2013 中打开项目属性的签名选项卡,则会显示未启用 ClickOnce 签名(无论配置和目标平台如何)。不要让这愚弄您,它在发布版本期间仍然会进行属性签名。选中此选项卡上的复选框将重新添加 SignManifests节点在 Project没有任何条件的水平让我们回到我们开始的地方。在其他选项卡中更改项目设置不会出现重新添加节点,因此您可以自由地在其他地方进行所需的项目属性更改。
  • 关于visual-studio-2010 - 如何在 Visual Studio 2013 中禁用调试版本的代码签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28568453/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com