30
loading...
This website collects cookies to deliver better user experience
dotnet restore
task:dotnet build
step:dotnet publish
together with the --runtime
option. In my case I want to produce a self-containing program for 64 bit Windows, why the command looks like this:dotnet publish --runtime win-x64
error NETSDK1047: Assets file '...\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v5.0/win-x64'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.
csproj
file, the project doesn't include a runtime as proposed by the error message:<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
RuntimeIdentifiers
element:<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
</PropertyGroup>
dotnet publish
step:C:\Program Files\dotnet\sdk\5.0.301\NuGet.targets(123,5): error : Unable to load the service index for source .../_packaging/Elmah.Io.Shared/nuget/v3/index.json.
C:\Program Files\dotnet\sdk\5.0.301\NuGet.targets(123,5): error : Response status code does not indicate success: 401 (Unauthorized).
dotnet restore
step which pointed out a custom NuGet feed to (also) restore packages from? Unfortunately, neither build
or publish
has this option, why I need to disable restore on those steps (no need to restore and build multiple times anyway). This can be done by modifying the build step:dotnet build --runtime win-x64 --no-restore
win-x64
runtime and don't do NuGet restore. We need the runtime parameter since dotnet publish
will no longer restore and build if required. The --no-restore
parameter instructs build not to restore NuGet packages.dotnet publish --runtime win-x64 --no-build mycli.csproj
--no-build
parameter, neither restore or build is executed as part of this step.