-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source-Only NuGet packages add <Compile Include="..." /> to csproj, resulting in build errors. #3269
Comments
Ping. Anybody there? |
can you please upload a zip with a repro. Maybe I find some time before next vacation |
PaketRepro.zip Steps to reproduce:
|
ok fixed in latest alpha |
@forki Unfortunately, files from the NuGet packages aren't copied to the directory anymore now (using paket 5.174.0). You can reproduce this with the zip file I provided earlier. |
@btodts to which directory? we now rely fully on the nuget functionality. I thought that was the plan here |
The project folder that contains the |
ok, but should't the PackageReference handle this now? how would it wor in vanilla nuget? It makes no sense to me yet |
If I understand https://aka.ms/sdkimplicititems correctly, the properties of the dotnet core SDK now contain globs to include files that should (or should not) be compiled during the MSBuild process, whereas the 'old' way is including those globs in the csproj file as
|
yes, but what do we need to change? how would it work in vanilla nuget? |
Well, upon |
FYI, I've updated the issue I previously posted over @ NuGet to investigate the missing behaviour when using .NET Core: NuGet/Home#7053 |
@forki I think this change introduced a new bug. After debugging with @btodts we found the following: In this commit: 4f40b2f When we revert this to the old syntax, we get the desired functionality again, seeing these are generated inside the csproj: <Content Include="MunicipalityRegistry.Api.Legacy.xml">
<Paket>True</Paket>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> The problem @btodts had was it would generate This actually comes from: Paket/src/Paket.Core/PaketConfigFiles/ProjectFile.fs Lines 1566 to 1567 in b3bf2fb
let determineBuildAction fileName (project:ProjectFile) =
match (Path.GetExtension fileName).ToLowerInvariant() with
| ext when Path.GetExtension project.FileName = ext + "proj"
-> BuildAction.Compile
| ".fsi" -> BuildAction.Compile
| ".xaml" -> BuildAction.Page
| ".ttf" | ".png" | ".ico" | ".jpg" | ".jpeg"| ".bmp" | ".gif"
| ".wav" | ".mid" | ".midi"| ".wma" | ".mp3" | ".ogg" | ".rma"
| ".avi" | ".mp4" | ".divx"| ".wmv" //TODO: and other media types
-> BuildAction.Resource
| _ -> BuildAction.Content I think (not sure how to do it), the match on If that makes any sense? Maybe you can shed a light on how to approach this change? Something along the lines of: let determineBuildAction fileName (project:ProjectFile) =
match (Path.GetExtension fileName).ToLowerInvariant() with
| ext when Path.GetExtension project.FileName = ext + "proj"
-> match getToolsVersion project with
| 15.0 -> BuildAction.Content
| _ -> BuildAction.Compile
| ".fsi" -> BuildAction.Compile
| ".xaml" -> BuildAction.Page
| ".ttf" | ".png" | ".ico" | ".jpg" | ".jpeg"| ".bmp" | ".gif"
| ".wav" | ".mid" | ".midi"| ".wma" | ".mp3" | ".ogg" | ".rma"
| ".avi" | ".mp4" | ".divx"| ".wmv" //TODO: and other media types
-> BuildAction.Resource
| _ -> BuildAction.Content |
PR coming.... Verified the proposal, fixes the issue and solves the regression |
Description
Paket Installing a source-only NuGet package adds a Compile element to the csproj file, which leads to build errors in the new dotnet sdk:
Duplicate Compile items were included. The .NET SDK includes Compile items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file.
Repro steps
Add e.g. TinyIoC to your
paket.dependencies
andpaket.references
of your dotnet 1.1+ console application.Run
paket Install
.Expected behavior
The files in the Content folder of the NuGet package (in TinyIoC's case,
TinyIoC.cs
) are added to the project. Since the dotnet sdk moved the globs to include compile items to the properties of the sdk, it isn't necessary that an element (<Compile Include="TinyIoC.cs" />
) is added to the cspoj. Expected behavior is therefore that this doesn't happen. (more info: https://aka.ms/sdkimplicititems)Actual behavior
It does :) A Compile element is added to the csproj, which causes build errors (see above).
Known workarounds
The error goes away when you remove the element from the csproj, but it is added again after every
paket Install
, which is unfortunate.The text was updated successfully, but these errors were encountered: