发布clickonce应用时发生错误。 当它以调试模式发布时,它工作正常,但是,如果我使用发布模式发布它并且抛出安全性异常。 Diggin in,我发现了清单之间的区别。 工作清单如下:
<applicationRequestMinimum>
<PermissionSet Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
发布模式中发布的清单有:
<applicationRequestMinimum>
<PermissionSet version="1" class="System.Security.NamedPermissionSet" Name="LocalIntranet" Description="Default rights given to applications on the local intranet" ID="Custom" SameSite="site">
<IPermission Read="USERNAME" version="1" class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<IPermission version="1" class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Unrestricted="true" />
<IPermission version="1" Permanent="True" Expiry="9223372036854775807" UserQuota="9223372036854775807" Allowed="AssemblyIsolationByUser" class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<IPermission version="1" class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Flags="ReflectionEmit, RestrictedMemberAccess" />
<IPermission version="1" class="System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Flags="Assertion, Execution, BindingRedirects" />
<IPermission version="1" class="System.Security.Permissions.UIPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Unrestricted="true" />
<IPermission version="1" class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Level="DefaultPrinting" />
<IPermission version="1" class="System.Security.Permissions.MediaPermission, WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Audio="SafeAudio" Image="SafeImage" Video="SafeVideo" />
<IPermission version="1" class="System.Security.Permissions.WebBrowserPermission, WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Level="Safe" />
<IPermission version="1" class="System.Net.DnsPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Unrestricted="true" />
<IPermission version="1" class="System.Security.Permissions.TypeDescriptorPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Unrestricted="true" />
</PermissionSet>
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
我发现此问题是因为我尝试使用VSTS Build Task,当我使用msbuild命令行发布时,这使用了Release模式。
如何强制生成第一种清单?
编辑:这是de .csproj文件
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{2B3F0BA0-0F55-4F3D-ADD4-5D5E0A19C85C}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WinSPC.Stratifications.View</RootNamespace>
<AssemblyName>WinSPC.Stratifications</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<InstallUrl>\\JAL01WINSPC\WinSPCRemote\Modulos\StratificationBotes\</InstallUrl>
<ProductName>WinSPC.Estratificación</ProductName>
<PublisherName>CdelIT</PublisherName>
<SuiteName>WinSPC.Estratificación</SuiteName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>index.htm</WebPage>
<ApplicationRevision>26</ApplicationRevision>
<ApplicationVersion>2.6.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</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>2</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</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>
<ManifestCertificateThumbprint>8EB250AABD2F38D9886B31E0FC3C06190BAC6D2A</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>View_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<TargetZone>Custom</TargetZone>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.3.0.19026, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=1.4.1.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.4.1\lib\net45\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MoreLinq, Version=2.0.20029.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
<HintPath>..\packages\morelinq.2.0.0\lib\net35\MoreLinq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OxyPlot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=638079a8f0bd61e9, processorArchitecture=MSIL">
<HintPath>..\packages\OxyPlot.Core.1.0.0\lib\net45\OxyPlot.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OxyPlot.Wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=75e952ba404cdbb0, processorArchitecture=MSIL">
<HintPath>..\packages\OxyPlot.Wpf.1.0.0\lib\net45\OxyPlot.Wpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.4.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ExtendedControls\ExtendedTreeView.cs" />
<Compile Include="ExtendedControls\TextBoxHelper.cs" />
<Compile Include="Helpers\ControlsWrapper.cs" />
<Compile Include="Helpers\ErrorHandler.cs" />
<Compile Include="Helpers\InputWrapper.cs" />
<Compile Include="Helpers\InvertBoolConverter.cs" />
<Compile Include="Helpers\StratificationControlWrapper.cs" />
<Compile Include="Helpers\TagControlWrapper.cs" />
<Compile Include="Helpers\ViewModelLocator.cs" />
<Compile Include="ViewModels\BoxPlotViewModel.cs" />
<Compile Include="ViewModels\DataCollectionViewModel.cs" />
<Compile Include="ViewModels\DataCollectionBoxPlotViewModel.cs" />
<Compile Include="Views\BoxPlot.xaml.cs">
<DependentUpon>BoxPlot.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DataCollection.xaml.cs">
<DependentUpon>DataCollection.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DataCollectionBoxPlot.xaml.cs">
<DependentUpon>DataCollectionBoxPlot.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SetStratification.xaml.cs">
<DependentUpon>SetStratification.xaml</DependentUpon>
</Compile>
<Page Include="Views\BoxPlot.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\CollectionPlanSelection.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DataCollection.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DataCollectionBoxPlot.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Login.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Main.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Helpers\MessageBoxService.cs" />
<Compile Include="Helpers\NavigateMessage.cs" />
<Compile Include="Helpers\StratificationItem.cs" />
<Compile Include="Helpers\ShuttingDownMessage.cs" />
<Compile Include="Interfaces\IMessageBoxService.cs" />
<Compile Include="Interfaces\IView.cs" />
<Compile Include="ViewModels\CollectionPlanSelectionViewModel.cs" />
<Compile Include="ViewModels\LoginViewModel.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="ViewModels\SetStratificationViewModel.cs" />
<Compile Include="Views\CollectionPlanSelection.xaml.cs">
<DependentUpon>CollectionPlanSelection.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Login.xaml.cs">
<DependentUpon>Login.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Main.xaml.cs">
<DependentUpon>Main.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Views\SetStratification.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="App.Release.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
<None Include="Tools\BuildScripts\version.ps1" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Exceptions\Exceptions.csproj">
<Project>{062B62A0-1C97-4662-9263-5AF3EFDC83BD}</Project>
<Name>Exceptions</Name>
</ProjectReference>
<ProjectReference Include="..\Extensions\Extensions.csproj">
<Project>{ECECE8C5-BFBC-4A05-9832-DD7FAFC75632}</Project>
<Name>Extensions</Name>
</ProjectReference>
<ProjectReference Include="..\Helpers\Helpers.csproj">
<Project>{63DDEE64-811D-4666-AF53-237498743DF8}</Project>
<Name>Helpers</Name>
</ProjectReference>
<ProjectReference Include="..\Model\Model.csproj">
<Project>{9D8E5FA6-89A8-4453-AAD2-6833CD0030FB}</Project>
<Name>Model</Name>
</ProjectReference>
<ProjectReference Include="..\Services\Services.csproj">
<Project>{FDFB442F-BF97-4BB1-84D4-433A1D1BFBD3}</Project>
<Name>Services</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\error.png" />
<Resource Include="Images\success.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\round-play-button.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\pocket_error.png" />
<Resource Include="Images\pocket_success.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\logo.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\exit.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\pocket.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\refresh.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\return-arrow.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\folder.png" />
<Resource Include="Images\collectionplan.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\back.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\logo.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="logo.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\logoEnvases.png" />
<Resource Include="Images\warning.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\select.png" />
<Resource Include="Images\unchecked.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Tools\BuildScripts\mage.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</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>
/ target:publish / p:ApplicationVersion = $(ApplicationVersion)/ p:UpdateEnabled = true / p:UpdateMode = Foreground / p:InstallUrl = $(URL)/ p:InstallFrom = Unc / p:ProductName = WinSPC。 Estratificación/ p:BootstrapperEnabled = true
更新: 在我的构建定义中,我有一个转换任务,我用它来进行ConnectionString更新。 如果我禁用此任务,则已发布的应用程序可以正常工作,但启用此任务(构建之前)后,已发布的应用程序将抛出安全性异常。 有什么想法吗?