1

I hope there is a simple answer to my question. I have updated a .NET 4.8 project to .NET 8.0. Now my project file is diffrent. That's clear. But how can I start my target now?

In .NET 4.8 I had one section:

<PropertyGroup>
   <BuildDependsOn>
      $(BuildDependsOn);
      LangResources;
    </BuildDependsOn>
</PropertyGroup>

And after this my definition for the target:

<Target Name="LangResources" Inputs="@(Resource)" Outputs="@(Resource -> '$(OutDir)%(Filename).resources')">
    <Message Text="Running ResourceCompiler... @(Resource)" Importance="high" />
    <GenerateResource Sources="@(Resource)" OutputResources="@(Resource -> '$(OutDir)%(Filename).resources')">
      <Output TaskParameter="OutputResources" ItemName="Resources" />
    </GenerateResource>
    <Message Text="Generated Resources... @(Resources)" Importance="high" />
</Target>

The update to .NET 8.0 with Visual Studio moves the "BuildDependsOn" section to the first <PropertyGroup> section and leaves the <Target> section unchanged. But the target is not called. No converting from the resx files to resources and also no logging. There is also no error message in the output section.

How do I call targets in the project file with .NET 8.0 like in .NET 4.8?

3
  • Es fehlte das "AfterTargets="Build"" im Target Knoten. Das BuildDependsOn ist dann auch nicht nötig. Damit erzeugt er nun wieder die Language Dateien. Commented Oct 7 at 9:41
  • If the question is "can I use targets in an SDK project" the answer is yes, or nothing would work. Just googling BuildDependsOn returns the targets doc page . The format is simplified, not completely new. Commented Oct 7 at 10:00
  • I assume you want to build a resource file before the build itself. The docs at Build a project that has resources should answer the question. <Target Name="Build" DependsOnTargets="Resources"> means the Build target depends on the Resources target, so when you call dotnet build the resource files will be built as well. Commented Oct 7 at 10:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.