Error Knowledge Base .NET NETSDK1005

NETSDK1005 / NETSDK1047: Assets file doesn't have a required target

The existing assets file was restored for a different target framework or runtime identifier than the current build or publish command.

What Broke in the Dependency Graph

The existing assets file was restored for a different target framework or runtime identifier than the current build or publish command.

Repair the dependency graph

Restore for the specific TFM or RID, and include -r <rid> if publishing with a RID.

Delete obj/ and bin/ if needed, then restore and build again.

Ensure RuntimeIdentifiers includes the RID used by build or publish.

Validation

Re-run the failing command and confirm the original code/message is gone, and confirm expected artifacts or outputs exist (packages restored, build/publish succeeds).

Why Resolution Broke

Usually this comes down to stale obj/ came from a restore that targeted different TFMs, you are building or publishing with -r <rid> but restored without that RID, or CI caches or shares obj/ across TFMs or RIDs.

Prove the Graph Is Clean Again

dotnet build or dotnet publish succeeds without NETSDK1005 or NETSDK1047.

obj/project.assets.json contains a target for the requested TFM, and RID when applicable.

Typical Output

error NETSDK1005: Assets file 'obj/project.assets.json' doesn't have a target for 'net8.0'.
error NETSDK1047: Assets file 'obj/project.assets.json' doesn't have a target for 'net8.0/win-x64'.

Mechanism

Assets file targets are keyed by TargetFramework, and sometimes by TargetFramework plus RuntimeIdentifier. If you build with a new TFM or RID but didn’t restore for it, NETSDK1005 or NETSDK1047 fires.

Keep the Dependency Graph Healthy

To prevent this, do not cache or share obj/ across different TFMs or RIDs, cache global packages instead, and always restore in the same configuration you build or publish.

Docs and source code

NETSDK1005 message template

Assets file missing a TargetFramework target. - GitHub

  <data name="AssetsFileMissingTarget" xml:space="preserve">
    <value>NETSDK1005: Assets file '{0}' doesn't have a target for '{1}'. Ensure that restore has run and that you have included '{2}' in the TargetFrameworks for your project.</value>
    <comment>{StrBegins="NETSDK1005: "}</comment>
  </data>

NETSDK1047 message template

Assets file missing a TargetFramework/RuntimeIdentifier target. - GitHub

  <data name="AssetsFileMissingRuntimeIdentifier" xml:space="preserve">
    <value>NETSDK1047: Assets file '{0}' doesn't have a target for '{1}'. Ensure that restore has run and that you have included '{2}' in the TargetFrameworks for your project. You may also need to include '{3}' in your project's RuntimeIdentifiers.</value>
    <comment>{StrBegins="NETSDK1047: "}</comment>
  </data>

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list