sdk: PP file output is not generated during the build

PP file output is not being generated during the build.

Steps

  1. dotnet new
  2. dotnet add package contentfilesexample -v 1.0.2
  3. dotnet restore
  4. Add to Program.cs Console.WriteLine(ExampleReader.GetDataText());
  5. dotnet build

Expected

ExampleReader will be in the current namespace from the pp file.

Actual

ExampleReader does not exist

Originally reported here https://github.com/NuGet/Home/issues/4803 //cc @damianh

From @natidea

I took a look at the pp file transformation issue and found a couple of things:

    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

Now I can use the Guard.

So somewhere along the way, some concepts may have been crossed. We default CopyLocalLockFileAssemblies to true in that target file, but it gets set to false in Microsoft.NET.Sdk.BeforeCommon.targets#L57. Perhaps the real issue is that the produce content assets task is tied to ResolveLockFileCopyLocalProjectDeps and should instead be triggered in some other way.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 32 (15 by maintainers)

Most upvoted comments

Please move this to milestone: 2.1.0

@ahmoh I’d argue that the ability to edit the source code of the package was a problem with the old system. What happens when a new version of the package is released? Editing the code is effectively forking the package. Source code packages are the wrong mechanism to distribute code which is intended to be edited. You should be using templates for that.

I tried to make it work with LiteGuard.Source package but the .pp file doesn’t get generated.

It seems we can now close this issue. Doing so now. If that’s not the case, just comment and we can re-activate, or file a new issue.

Lol worth a shot- thanks man!

@adamralph - Thank you for the link. I will check it out!

The example I provided was just a portion of the overall package we were building. The other part(s) of the package contained a Xamarin.Forms theme (resource dictionary) as well as some other Xamarin.Forms controls. The overall package was designed to completely theme each of our new and existing applications to the corporate “theme”/“layout” (which in Xamarin.Forms requires supplemental files to added/updated to achieve).

I suppose it is just frustrating that we can no longer copy files to disk while managing versions via NuGet Package Manager- especially considering that said functionality was present in previous versions.

Can we still copy files to disc using non-.NET Standard libraries? If so, would you mind sharing how we can still do this? I heard mention of .NET Standard packages using Init.ps1 to copy files into the user’s project (somehow)? Any information would be greatly appreciated!

There’s also the new dotnet new templates which also supports item templates. Those can be installed via dotnet new --install NuGet.Pkg.Name.Of.TemplatesPkg. This could allow for dotnet new dnaconfig.

Dropping files into the project will depend on the project type…

Quite a few projects used app.config transforms that were applied to the project’s app.config file. But since not all runtimes (.NET Core) use this file or relevant sections of this file, that may be pretty useless.

Source code packages are the wrong mechanism to distribute code which is intended to be edited. You should be using templates for that.

@adamralph Do you mean Visual Studio Project Templates or something else (that can be distributed via NuGet)?

The nice thing about NuGet is the composability it gives us, and how easy it is to install from the PowerShell console. Let’s say I want to create

With the old NuGet Package reference model, I can:


How would the above scenario work with the templates you mentioned?

If they were project templates, I’d have to choose 1 - either start with an Excel-DNA project template, or a DevExpress project template or a Costura.Fody project template… That doesn’t work.

If they were project item templates, I’d have to install 6 different things (3 NuGet packages and 3 VSIX) instead of 3 - or am I missing something?

@adamralph I want the user to be able to find the source file easily so he/her can edit it. Now it’s hidden in my opinion. Aslo this documentation is misleading, you think that the files under contentFiles/any/any/Source.cs.pp will be installed in the root folder of the project.

Finally released LibLog v5.0.0 with netstandard2.0 and SDK project support (It won’t work in non-sdk projects, previous version should be used for that).

@adamralph thanks for the example, but I was able to get that outcome also before. I’m disappointed that this feature doesn’t work in .net core as it does in .net framework project.

This is important for customers to move from packages.config to PackageReference, so can we get some traction on it? And tries to make it for 2.1.0?