Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Creating a NuGet package containing a .NET class library to copy sass files to a .NET consumer project and allow those files to be used and edited

$
0
0

I am attempting to create a NuGet package to copy sass files to a consumer project. I am able to see the files inside the consumer project (like in the image below) But they are locked and the file paths still reference the NuGet package project on my local machine.

Files from NuGet package

The NuGet project is not published it is just packed to a folder on my local which is referenced in the consumer project to install/update.

Here are my project files for the NuGet package:

I suspect the .targets file is not working correctly as I don't see the message that is in there when building or installing. It seems the reference to the files in the consumer project just comes from the line in the .nuspec that sets the target to "contentFiles\any\any\Theming".

.csproj file:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net8.0</TargetFramework><GeneratePackageOnBuild>true</GeneratePackageOnBuild><PackageId>Theming</PackageId><Version>1.1.5</Version><Authors>author</Authors><Description>theming</Description><PackageTags>sass scss copy</PackageTags><NuspecFile>Theming.nuspec</NuspecFile></PropertyGroup><ItemGroup><None Update="sass\**\*.scss"><Pack>true</Pack><PackagePath>Sass\</PackagePath></None><None Update="build\Theming.targets"><Pack>true</Pack><PackagePath>build\</PackagePath></None></ItemGroup></Project>

.nuspec file:

<?xml version="1.0"?><package><metadata><id>Theming</id><version>1.1.5</version><authors>author</authors><owners>owner</owners><requireLicenseAcceptance>false</requireLicenseAcceptance><description>Theming</description><contentFiles><files include="Sass\**\*.scss" buildAction="None" copyToOutput="true" flatten="true" /></contentFiles></metadata><files><file src="Sass\**\*.scss" target="contentFiles\any\any\Theming" /><file src="build\Theming.targets" target="build\Theming.targets" /></files></package>

.targets file:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><Target Name="Theming" AfterTargets="Build"><Message Text="Copying SASS files to $(MSBuildProjectDirectory)\Theming" Importance="High" /><ItemGroup><SassFiles Include="$(MSBuildThisFileDirectory)Sass\**\*.scss" /></ItemGroup><Copy SourceFiles="@(SassFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Theming" /></Target></Project>

If I try to explicitly include the files in the consumer project it cannot find them:

<ItemGroup><None Include="Theming\_theming.scss"><CopyToOutputDirectory>Always</CopyToOutputDirectory></None><None Include="Theming\_generic-names.scss"><CopyToOutputDirectory>Always</CopyToOutputDirectory></None><None Include="Theming\_default-variables.scss"><CopyToOutputDirectory>Always</CopyToOutputDirectory></None></ItemGroup>

Result of the above:

files after include


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>