(Повторная) ошибка компиляции после успешной сборки

#c# #.net #compiler-errors #csproj #ilrepack

#c# #.net #ошибки компилятора #csproj #ilrepack

Вопрос:

Моя текущая проблема заключается в том, что я хочу использовать ILRepack для объединения всех моих необходимых «Ссылок» в один .exe, но он работает не так, как предполагалось.

В настоящее время я использую C # .NET 4.8 в своем проекте, у меня есть 3 .dll, которые я хочу объединить. Сам .exe работает, но IRL не переупаковывает их. Небольшое примечание, я только выпускаю / отлаживаю свой .exe в «формате» x64, поэтому все настроено на это, но это не должно быть проблемой:/

Это похоже на сбой при попытке его переупаковки.

Мой текущий .csproj, он же MSBuildTask (должен запускаться только при сборке «релиза», что он и делает.)

  <Target Name="ILRepack" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<PropertyGroup>
  <WorkingDirectory>$(MSBuildThisFileDirectory)bin$(Configuration)$(TargetFramework)</WorkingDirectory>
</PropertyGroup>
<ILRepack OutputType="$(OutputType)" MainAssembly="$(AssemblyName).exe" OutputAssembly="$(AssemblyName).exe" InputAssemblies="$(WorkingDirectory)*.dll" WilcardInputAssemblies="true" WorkingDirectory="$(WorkingDirectory)" />
</Target>
  

Ошибка, которую я получаю ( одно предупреждение):

 Error       Object reference not set to an instance of an object.
   at ILRepacking.Steps.Win32Resources.PE.ImageWriter.CopySection(Section from, Section to)
   at ILRepacking.Steps.Win32Resources.PE.ImageWriter.Write()
   at ILRepacking.Steps.Win32Resources.Win32ResourceStep.Patch(String outFile)
   at ILRepacking.ILRepack.Repack()
   at ILRepack.MSBuild.Task.ILRepack.Execute()  SCPstealth  C:GITSCPSL-stealthSCPstealthSCPstealth.csproj   213 
   
Warning     ILRepack: Duplicate ignored: method. Mono.Cecil type: MethodDefinition. SCPstealth  C:GITSCPSL-stealthSCPstealthSCPstealth.csproj   213 
  

Весь мой .csproj

 <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..packagesILRepack.MSBuild.Task.2.0.13buildILRepack.MSBuild.Task.props" Condition="Exists('..packagesILRepack.MSBuild.Task.2.0.13buildILRepack.MSBuild.Task.props')" />
  <Import Project="..packagesILRepack.2.0.18buildILRepack.props" Condition="Exists('..packagesILRepack.2.0.18buildILRepack.props')" />
  <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>{BE2B5961-DDDE-45F2-B25F-76BD87D36CF2}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <RootNamespace>SCPstealth</RootNamespace>
    <AssemblyName>SCPstealth</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <Deterministic>true</Deterministic>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <PublishUrl>publish</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>x64</PlatformTarget>
    <DebugSymbols>false</DebugSymbols>
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>binDebug</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>x64</PlatformTarget>
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>binRelease</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>false</DebugSymbols>
    <OutputPath>binDebug</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <DebugType>none</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <Optimize>true</Optimize>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>binRelease</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>none</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <DebugSymbols>false</DebugSymbols>
    <DocumentationFile>
    </DocumentationFile>
  </PropertyGroup>
  <PropertyGroup>
    <StartupObject>SCPstealth.MainModule</StartupObject>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationIcon>ResourcesstealthIcon.ico</ApplicationIcon>
  </PropertyGroup>
  <PropertyGroup>
    <TargetZone>
    </TargetZone>
  </PropertyGroup>
  <PropertyGroup>
    <GenerateManifests>false</GenerateManifests>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationManifest>Propertiesapp.manifest</ApplicationManifest>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Guna.UI">
      <HintPath>..Frameworks amp;amp; LibsGuna.UIGuna.UI-Framework-Lib-masterGuna.UI WinForms.net 4.0Guna.UI.dll</HintPath>
      <Private>True</Private>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>
    <Reference Include="Guna.UI2">
      <HintPath>..Frameworks amp;amp; LibsGuna.UIGuna.UI-Framework-Lib-masterGuna.UI2 WinForms.net 4.0Guna.UI2.dll</HintPath>
      <Private>True</Private>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>
    <Reference Include="Memory, Version=1.2.21.0, Culture=neutral, processorArchitecture=AMD64">
      <HintPath>..packagesMemory.dll.x64.1.2.21libnetstandard2.0Memory.dll</HintPath>
      <Private>True</Private>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>
    <Reference Include="Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesMicrosoft.Build.Framework.15.9.20libnet46Microsoft.Build.Framework.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesMicrosoft.Build.Utilities.Core.15.9.20libnet46Microsoft.Build.Utilities.Core.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.Setup.Configuration.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesMicrosoft.VisualStudio.Setup.Configuration.Interop.1.16.30libnet35Microsoft.VisualStudio.Setup.Configuration.Interop.dll</HintPath>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesSystem.Collections.Immutable.1.5.0libnetstandard2.0System.Collections.Immutable.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="System.Configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Numerics" />
    <Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesSystem.Runtime.InteropServices.RuntimeInformation.4.3.0libnet45System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
      <Private>True</Private>
      <Private>False</Private>
    </Reference>
    <Reference Include="System.Security.Principal.Windows, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesSystem.Security.Principal.Windows.4.7.0libnet461System.Security.Principal.Windows.dll</HintPath>
      <Private>False</Private>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>
    <Reference Include="System.Xaml" />
    <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.Net.Http" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="MainModule.cs" />
    <Compile Include="stealthMenu.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="stealthMenu.Designer.cs">
      <DependentUpon>stealthMenu.cs</DependentUpon>
    </Compile>
    <Compile Include="PropertiesAssemblyInfo.cs" />
    <Compile Include="TainerModule.cs" />
    <EmbeddedResource Include="stealthMenu.resx">
      <DependentUpon>stealthMenu.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="PropertiesResources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="PropertiesResources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
      <DesignTime>True</DesignTime>
    </Compile>
    <None Include="packages.config" />
    <None Include="Propertiesapp.manifest" />
    <None Include="PropertiesSettings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <Compile Include="PropertiesSettings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Include="Resourcesstealthmeme.png" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="ResourcesstealthIcon.ico" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include=".NETFramework,Version=v4.8">
      <Visible>False</Visible>
      <ProductName>Microsoft .NET Framework 4.8 %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>
  <Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />
  <Target Name="ILRepack" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
    <PropertyGroup>
      <WorkingDirectory>$(MSBuildThisFileDirectory)bin$(Configuration)$(TargetFramework)</WorkingDirectory>
    </PropertyGroup>
    <ILRepack OutputType="$(OutputType)" MainAssembly="$(AssemblyName).exe" OutputAssembly="$(AssemblyName).exe" InputAssemblies="$(WorkingDirectory)*.dll" WilcardInputAssemblies="true" WorkingDirectory="$(WorkingDirectory)" />
  </Target>
  <PropertyGroup>
    <PostBuildEvent>cd $(TargetDir)
del *.xml
del *.exe.config</PostBuildEvent>
  </PropertyGroup>
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..packagesILRepack.2.0.18buildILRepack.props')" Text="$([System.String]::Format('$(ErrorText)', '..packagesILRepack.2.0.18buildILRepack.props'))" />
    <Error Condition="!Exists('..packagesILRepack.MSBuild.Task.2.0.13buildILRepack.MSBuild.Task.props')" Text="$([System.String]::Format('$(ErrorText)', '..packagesILRepack.MSBuild.Task.2.0.13buildILRepack.MSBuild.Task.props'))" />
  </Target>
</Project>
  

Комментарии:

1. У меня та же проблема. Ошибка исчезает, если вы не используете x64 в PlatformTarget.