File tree Expand file tree Collapse file tree 8 files changed +564
-0
lines changed Expand file tree Collapse file tree 8 files changed +564
-0
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ namespace Helpers
2+ {
3+ internal class Class1
4+ {
5+ public static void SayHello ( ) => global ::System . Console . WriteLine ( "Hello!" ) ;
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <TargetFramework >netstandard2.0</TargetFramework >
5+ <ImplicitUsings >disable</ImplicitUsings >
6+ <Nullable >disable</Nullable >
7+ <NuSpecFile >SourceOnlyExample.nuspec</NuSpecFile >
8+ </PropertyGroup >
9+
10+ </Project >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <package xmlns =" http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" >
3+ <metadata >
4+ <id >SourceOnlyExample</id >
5+ <version >1.0.0</version >
6+ <developmentDependency >true</developmentDependency >
7+ <authors >Andrew Lock</authors >
8+ <license type =" expression" >MIT</license >
9+ <requireLicenseAcceptance >false</requireLicenseAcceptance >
10+ <projectUrl >https://andrewlock.net/creating-source-only-nuget-packages/</projectUrl >
11+ <description >An example source-code only package</description >
12+ <tags >source compiletime</tags >
13+ </metadata >
14+ <files >
15+ <!--
16+ The files are included twice:
17+ As contentFiles (for PackageReferences)
18+ As content (for packages.config).
19+ -->
20+ <file src =" *.cs" target =" contentFiles/cs/netstandard2.0/SourceOnlyExample/" />
21+ <file src =" *.cs" target =" content/cs/netstandard2.0/SourceOnlyExample/" />
22+
23+ <!-- Hide content files from Visual Studio solution explorer -->
24+ <file src =" SourceOnlyExample.props" target =" build/SourceOnlyExample.props" />
25+ </files >
26+ </package >
Original file line number Diff line number Diff line change 1+ <Project >
2+ <!--
3+ Hide content files from Visual Studio solution explorer. Adapted from:
4+ https://til.cazzulino.com/dotnet/nuget/hide-contentfiles-from-your-nuget-packages
5+ -->
6+ <ItemGroup >
7+ <Compile Update =" @(Compile)" >
8+ <Visible Condition =" '%(NuGetItemType)' == 'Compile' and '%(NuGetPackageId)' == 'SourceOnlyExample'" >false</Visible >
9+ </Compile >
10+ </ItemGroup >
11+ </Project >
Original file line number Diff line number Diff line change 1+ Helpers . Class1 . SayHello ( ) ;
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <TargetFramework >net8.0</TargetFramework >
6+ <ImplicitUsings >enable</ImplicitUsings >
7+ <Nullable >enable</Nullable >
8+ </PropertyGroup >
9+
10+ <ItemGroup >
11+ <PackageReference Include =" SourceOnlyExample" Version =" 1.0.0" >
12+ <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
13+ <PrivateAssets >all</PrivateAssets >
14+ </PackageReference >
15+ </ItemGroup >
16+
17+ </Project >
Original file line number Diff line number Diff line change 1+ $ErrorActionPreference = " Stop"
2+ dotnet build - c Release ./ SourceOnlyExample/ SourceOnlyExample.csproj
3+ dotnet pack - c Release ./ SourceOnlyExample/ SourceOnlyExample.csproj
4+ rm - r - Force ./ packages/*
5+ dotnet remove ./ TestApp/ TestApp.csproj package SourceOnlyExample
6+ dotnet add ./ TestApp/ TestApp.csproj package SourceOnlyExample -- package- directory ./ packages -- source ./ SourceOnlyExample/ bin/ Release/
7+ dotnet build ./ TestApp/ TestApp.csproj -- packages ./ packages
8+ dotnet run -- no- build -- project ./ TestApp/ TestApp.csproj
You can’t perform that action at this time.
0 commit comments