fsbolero / Template

dotnet cli template to create Bolero applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Paket bootstrap fails when switching OSes

ADIX7 opened this issue · comments

I edit my repo from Windows and also from Ubuntu. When I try to build after switching OS, paket.bootstrapper.proj tries to install paket but dotnet tells it already exists. I modified paket.bootstrapper.proj so no it's working. You can add to the repo if you will.

<Project ToolsVersion="15.0">

    <Import Project="$(MSBuildThisFileDirectory)paket.bootstrapper.props" Condition="Exists('$(MSBuildThisFileDirectory)paket.bootstrapper.props')" />

    <PropertyGroup>
        <RepoRoot>$(MSBuildThisFileDirectory.TrimEnd('\\').TrimEnd('/'))</RepoRoot>

        <PaketBootstrapperExeWin>$(RepoRoot)\paket.bootstrapper.exe</PaketBootstrapperExeWin>
        <PaketBootstrapperExeNonWin>$(RepoRoot)/paket.bootstrapper</PaketBootstrapperExeNonWin>
        <PaketBootstrapperExe>$(PaketBootstrapperExeWin)</PaketBootstrapperExe>
        <PaketBootstrapperExe Condition=" '$(OS)' != 'Windows_NT' ">$(PaketBootstrapperExeNonWin)</PaketBootstrapperExe>

        <PaketExeWin>$(RepoRoot)\paket.exe</PaketExeWin>
        <PaketExeNonWin>$(RepoRoot)/paket</PaketExeNonWin>
        <PaketExe>$(PaketExeWin)</PaketExe>
        <PaketExe Condition=" '$(OS)' != 'Windows_NT' ">$(PaketExeNonWin)</PaketExe>
    </PropertyGroup>

    <Target Name="RemoveWinPaket" Condition=" '$(OS)' != 'Windows_NT' ">
        <Message Text='Removing Windows version of paket' Importance="High"/>
        <RemoveDir Directories="$(RepoRoot)/.store" />
        <Delete Files='$(PaketBootstrapperExeWin)' />
        <Delete Files='$(PaketExeWin)' />
    </Target>

    <Target Name="RemoveNonWinPaket" Condition=" '$(OS)' == 'Windows_NT' ">
        <Message Text='Removing non Windows version of paket' Importance="High"/>
        <RemoveDir Directories="$(RepoRoot)/.store" />
        <Delete Files='$(PaketBootstrapperExeNonWin)' />
        <Delete Files='$(PaketExeNonWin)' />
    </Target>

    <Target Name="RemoveOtherOSsPaket" DependsOnTargets="RemoveWinPaket;RemoveNonWinPaket">
    </Target>

    <Target Name="InstallPaketBootstrapper" DependsOnTargets="RemoveOtherOSsPaket" Condition="Exists('$(PaketBootstrapperExe)') == false">
        <Message Text='Installing paket.bootstrapper' Importance="High"/>
        <PropertyGroup>
            <InstallBootstrapperCommand>dotnet tool install paket.bootstrapper --tool-path "$(RepoRoot)"</InstallBootstrapperCommand>
            <InstallBootstrapperCommand Condition=" '$(PaketBootstrapperVersion)' != '' ">$(InstallBootstrapperCommand) --version "[$(PaketBootstrapperVersion)]"</InstallBootstrapperCommand>
            <InstallBootstrapperCommand Condition=" '$(PaketBootstrapperFeed)' != '' ">$(InstallBootstrapperCommand) --add-source "$(PaketBootstrapperFeed)"</InstallBootstrapperCommand>
            <InstallBootstrapperCommand Condition=" '$(InstallBootstrapperOtherArgs)' != '' ">$(InstallBootstrapperCommand) $(InstallBootstrapperOtherArgs)"</InstallBootstrapperCommand>
        </PropertyGroup>
        <Exec Command="$(InstallBootstrapperCommand)" WorkingDirectory="$(RepoRoot)" />
    </Target>

    <Target Name="InstallPaket" DependsOnTargets="InstallPaketBootstrapper" Condition="Exists('$(PaketExe)') == false">
        <Message Text='Running paket.bootstrapper to install paket' Importance="High"/>
        <PropertyGroup>
            <RunBootstrapperCommand>$(PaketBootstrapperExe) --as-tool --output-dir=$(RepoRoot)</RunBootstrapperCommand>
            <RunBootstrapperCommand Condition=" Exists('$(RepoRoot)\paket.bootstrapper.exe.config') ">$(RunBootstrapperCommand) --config-file=$(RepoRoot)/paket.bootstrapper.exe.config</RunBootstrapperCommand>
            <RunBootstrapperCommand Condition=" '$(RunBootstrapperOtherArgs)' != '' ">$(RunBootstrapperCommand) $(RunBootstrapperOtherArgs)</RunBootstrapperCommand>
        </PropertyGroup>
        <Exec Command='$(RunBootstrapperCommand)' WorkingDirectory="$(RepoRoot)" />
    </Target>

    <Target Name="Restore" DependsOnTargets="InstallPaket">
        <Message Text='Paket ready, checking version:' Importance="High"/>
        <Exec Command='$(PaketExe) --version' WorkingDirectory="$(RepoRoot)" />
    </Target>

    <Import Project="$(MSBuildThisFileDirectory)paket.bootstrapper.targets" Condition="Exists('$(MSBuildThisFileDirectory)paket.bootstrapper.targets')" />

</Project>

Can you submit this as a PR? Thanks!

Done! Check task/variable names. I just typed what jumped out of my mind. They might be not the best.

Closing as this was fixed by PR #6.