Skip to content

Paket install moves <Import Project=".paket\Paket.Restore.targets" /> to the end #3209

Closed

Description

@matthid

Description

If you have a customized SDK project where you manually depend on the import order of the SDK:

<Project>
  <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <Import Project=".paket\Paket.Restore.targets" />
  <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
  <PropertyGroup>
    <RepoRootDir>$([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)"))</RepoRootDir>
    <BuildDependsOn>
    </BuildDependsOn>
    <CoreBuildDependsOn>
    </CoreBuildDependsOn>
    <FakeParallelArg Condition="$(FakeParallel) != '0' ">--parallel $(FakeParallel)</FakeParallelArg>
    <FakeVerboseArg Condition="$(FakeVerbose) != 'false' ">-v</FakeVerboseArg>
    <ActivateBuildServer Condition="$(FakeParallel) == '0' ">--fsiargs --define:isNotParallel</ActivateBuildServer>
	<FakeConfigurationArg  Condition="$(Configuration) != '' ">-e Configuration=$(Configuration)</FakeConfigurationArg>
    <FakeCommandLine  Condition="'$(FakeTarget)'==''">dotnet fake $(FakeVerboseArg) run $(ActivateBuildServer) build.fsx $(FakeParallelArg) $(FakeConfigurationArg)</FakeCommandLine>
    <FakeCommandLine  Condition="'$(FakeTarget)'!=''">dotnet fake run build.fsx -t $(FakeTarget) $(FakeConfigurationArg) -s</FakeCommandLine>
  </PropertyGroup>
  <Target Name="Build">
    <Message Importance="High" Text="Executing $(FakeCommandLine)" />
    <Exec IgnoreStandardErrorWarningFormat="true" Command="$(FakeCommandLine)" WorkingDirectory="$(RepoRootDir)" />
  </Target>
  <Target Name="Pack">
  </Target>
  <Target Name="Test">
  </Target>
  <Target Name="VSTest" DependsOnTargets="Test" />
</Project>

Then paket will move the paket-import to the end.

Repro steps

Run paket update or paket install

Expected behavior

Paket should leave my order in place and ignore the file if the import is already added.

Actual behavior

Paket re-writes the file

Known workarounds

Revert the change manually after update/install

Activity

  1. added a commit that references this issue on Aug 26, 2026
    e128548
  2. github-actions commented on Aug 26, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I opened a draft PR that fixes the root cause: installForDotnetSDK was unconditionally removing and re-appending the Paket.Restore.targets import on every install/restore, which always moves it to the end of the file. The fix skips the remove/re-add when the import is already present at the same path, preserving its original position.

    See the linked pull request for details (build passes, existing ProjectFile test suite green). Feedback welcome!

    Generated by 🌈 Repo Assist, see workflow run. Learn more.
    Comment /repo-assist to run again

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@ae8d551f07c7ed7619f8c58c7bb4c3ac89395d38
    
  3. added a commit that references this issue on Aug 27, 2026
  4. added a commit that references this issue on Aug 27, 2026
    8f2ef43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions