How to specify a .targets file as build group in the nuget package without nuspec file

38 Views Asked by At

I added a target file to my rcl project in the build directory, I have these properties specified in rcl project so that packaging occures without a nuspec file:

<PropertyGroup>
  <TargetFramework>net8.0</TargetFramework>
  <Nullable>enable</Nullable>
  <ImplicitUsings>enable</ImplicitUsings>
  <AssemblyVersion>1.0.0.8801</AssemblyVersion>
  <SignAssembly>False</SignAssembly>
  <IsPackable>true</IsPackable>
  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>   
  <PackageId>StaticAssets</PackageId>
  <Version>1.0.5</Version>
  <Authors>mz</Authors>
  <Company>harris</Company>
  <Title>StaticAssets</Title>    
  <PackageOutputPath>$(SolutionDir)\Packages</PackageOutputPath>
</PropertyGroup>

Now I have these so that .targets file is packed:

<ItemGroup>
  <None Update="build\StaticAssets.targets">
    <Pack>true</Pack>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </None>
</ItemGroup>

but in my main project after adding this rcl package the .targets file is in the contentFiles folder I want it to be in the build folder so that it is built every time the project builds, also this is the targets file content I put in the build folder of the rcl project:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="CopyStaticAssets" AfterTargets="Build">
        <ItemGroup>
            <StaticAssets Include="$(MSBuildThisFileDirectory)..\contentFiles\any\any\assets\**\*.*" />
        </ItemGroup>
      <Copy SourceFiles="@(StaticAssets)"
            DestinationFiles="@(StaticAssets->'$(ProjectDir)\wwwroot\%(RecursiveDir)%(Filename)%(Extension)')" />
              <!--DestinationFolder="$(OutputPath)\wwwroot\assets\%(RecursiveDir)" SkipUnchangedFiles="true" />-->
    </Target>
</Project>
0

There are 0 best solutions below