MrCalvin
MrCalvin

Reputation: 1825

Cannot publish .NET 4.7.2 project from console error MSB4062

Trying to publish a console C# .NET Framework 4.7.2 project using this command

dotnet publish W-INST.csproj --configuration Release --runtime win-x64 --no-self-contained --framework net472 /p:PublishReadyToRun=true --output=bin\Publish\

But it get the error

C:\Program Files\dotnet\sdk\6.0.402\Microsoft.Common.CurrentVersion.targets(4497,5):
error MSB4062: The "Microsoft.Build.Tasks.GenerateTrustInfo" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I'm able to publish from VS 2022 gui.

Project-file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <ProjectGuid>{BE762AA2-11EC-4ED3-95D0-B871E6D1C20A}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>W_INST_W_KOPIA</RootNamespace>
    <AssemblyName>W-INST_W-KOPIA</AssemblyName>
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <Deterministic>true</Deterministic>
    <GenerateManifests>false</GenerateManifests>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <ErrorReport>prompt</ErrorReport>
    <StartupObject>Program</StartupObject>
    <ApplicationIcon>icon1.ico</ApplicationIcon>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <TargetZone>LocalIntranet</TargetZone>
    <BaseOutputPath>bin~NB\Build\</BaseOutputPath>
    <OutputPath>$(BaseOutputPath)\$(Configuration)</OutputPath>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
    <PublishUrl>bin~NB\publish\</PublishUrl>
    <Install>false</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>false</MapFileExtensions>
    <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
    <ApplicationRevision>1</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <UseApplicationTrust>false</UseApplicationTrust>
    <PublishWizardCompleted>true</PublishWizardCompleted>
    <BootstrapperEnabled>false</BootstrapperEnabled>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <DefineConstants>TRACE</DefineConstants>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="icon1.ico" />
    <None Include="App.config" />
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Xml" />
  </ItemGroup>

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Upvotes: 0

Views: 1083

Answers (0)

Related Questions