sdk: PP file output is not generated during the build
PP file output is not being generated during the build.
Steps
- dotnet new
- dotnet add package contentfilesexample -v 1.0.2
- dotnet restore
- Add to Program.cs
Console.WriteLine(ExampleReader.GetDataText()); - 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:
- For the ContentFilesExample package, I don’t see pp files listed as dependencies in the assets file. They occur in the “libraries” but we are only processing content from the active TFM here: Microsoft.PackageDependencyResolution.targets#L213
- For the LiteGuard package, I do see the pp files in the dependencies, but they were not being processed because
CopyLocalLockFileAssemblies=false here: Microsoft.PackageDependencyResolution.targets#L414 I was able to fix this by setting the property in my project file:
<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)
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.Sourcepackage 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 newtemplates which also supports item templates. Those can be installed viadotnet new --install NuGet.Pkg.Name.Of.TemplatesPkg. This could allow fordotnet 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.
@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:
.dnaconfig template file that I can modify / customize for my project.xmlconfig template file that I can modify / customize for my projectHow 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 aDevExpress project templateor aCostura.Fodyproject 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?