-
Notifications
You must be signed in to change notification settings - Fork 520
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
When setting framework restriction on nuget package with .props and .targets, elements in .csproj are moved to wrong location #1898
Comments
can you please add a zip with the repro? |
reproduce.bat |
In your sample the props are still above all references and the targets below all references. Do you think we should move it just below the latst "PropertyGroup"? |
.props should be before the first "PropertyGroup" and So I think that for .targets it still works, it's the .props import that is moved from line 3 to line 99, and this fails |
no we can't move it before the propertygroups since the constants for the choose nodes are only defined after the propertygroupds. anyways I'm pushing a fix which moves it up. Please give it a try |
so it's released. can you please give it a shot? |
Same result, The first import project element is moved. Maybe we are looking at the issue the wrong way. What if the problem should be how to ignore framework restriction. My paket.dependencies has a lot of duplicated
what if I could write this at the top of package.dependencies as described in the documentation
and then for my dependency that should not have any framework restriction i just ignore them
|
it's expected that it is moved below the propertygroups. question is why that is not good enough |
Why is it expected to be moved below the first PropertyGroup? Nuget adds the import project at the top before the first PropertyGroup This is the first PropertyGroup in all csproj files. MSBuild reads csproj from the top to the bottom, so if you check the TargetFrameworkProfiler or DefineConstants, they have a condition attribute saying that if already defined, ignore this. To replace these values from the imported project, it has to come before the first PropertyGroup. <PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<ProjectGuid>{AA7FD029-8F87-4804-B9EA-0B8549ACEAB4}</ProjectGuid>
<OutputType>Library</OutputType>
....
<TargetFrameworkProfile Condition="'$(TargetFrameworkVersion)' == 'v4.0'">Client</TargetFrameworkProfile>
<DefineConstants Condition="'$(DefineConstants)' == ''">NET40;NET45;NET451;NET452;NET46</DefineConstants>
</PropertyGroup> If I just could ignore framework restriction on this particular package and let all other packages have it, then this would not be an issue. If I don't add any framework restrictions on this package, the Import element is placed at the correct location |
Because the choose nodes depend on the target framework which is defined in Am 30.08.2016 7:48 vorm. schrieb "Thomas Heggelund" <
|
A chicken and egg issue then. How would someone target multiple frameworks if you cannot change the TargetFramework? My solution to the problem is to add framework restriction to all dependencies but the multitarget dependency. What if I could do as I suggested earlier, to set framework restriction at the top, and then, for this particular package I set it to none/ignore/or some ignore constant. That way, I do not have to duplicate the framework restriction on all dependencies |
Description
Added framework: net452, net46, net461 to specification in paket.dependencies
From
To
Expected behavior
Should not change location of imports. .props import should be at the top, .targets should be at the bottom.
Actual behavior
Known workarounds
Solution to the issue is to not add framework restriction to package but then I need to add framework restriction to all other packages instead of just using framework restriction at the top
The text was updated successfully, but these errors were encountered: