Skip to content
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

How to use Paket in solutions that contain Service Fabric projects (.sfproj) #2977

Closed
pshrosbree opened this issue Jan 10, 2018 · 9 comments
Closed

Comments

@pshrosbree
Copy link

Description

I have a solution that is comprised of SDK projects and a Service Fabric project (.sfproj). I am converting these from NuGet to Paket, but it not clear to me how the .sfproj should be converted. The .sfproj is generated by Visual Studio when creating a Service Fabric project, and looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles">
  <Import Project="..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
  <PropertyGroup>
    <DotnetBuildFolder>..\..\..\..\tools\build-dotnet</DotnetBuildFolder>
  </PropertyGroup>
  <Import Project="$(DotnetBuildFolder)\ServiceFabricPackage.targets" />
  <PropertyGroup Label="Globals">
    <ProjectGuid>e1296024-58b6-4e25-843e-b9faa9b07be6</ProjectGuid>
    <ProjectVersion>1.6</ProjectVersion>
    <MinToolsVersion>1.5</MinToolsVersion>
  </PropertyGroup>
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <None Include="ApplicationPackageRoot\ApplicationManifest.xml" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="ApplicationParameters\Local.1Node.xml" />
    <Content Include="PublishProfiles\Local.1Node.xml" />
  </ItemGroup>
  <ItemGroup>
    <None Include="ApplicationParameters\Local.5Node.xml" />
    <None Include="PublishProfiles\Local.5Node.xml" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Scripts\Deploy-FabricApplication.ps1" />
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\svc\EventHubReader.Factory\EventHubReader.Factory.csproj" />
    <ProjectReference Include="..\..\svc\EventHubReader.Watchdog\EventHubReader.Watchdog.csproj" />
    <ProjectReference Include="..\..\svc\EventHubReader\EventHubReader.csproj" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
  <PropertyGroup>
    <ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath>
  </PropertyGroup>
  <Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" />
  <Import Project="..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
  <Target Name="ValidateMSBuildFiles">
    <Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" />
    <Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" />
  </Target>
</Project>

Lines 4 -7 were added by me.

How should I change this to use Paket?

@forki forki closed this as completed in 9229896 Jan 11, 2018
forki added a commit that referenced this issue Jan 11, 2018
@pshrosbree
Copy link
Author

@forki I see you added some sfproj awareness in the commit above. Thank you. How should I leverage that? Should paket now just work? Do I need to do anything to the sfproj I have in my paketized solution?

@forki
Copy link
Member

forki commented Jan 11, 2018

there is a good chance that it now "just works". But I don't use sfproj myself so I can't verify

@pshrosbree
Copy link
Author

Thanks. I'm out today, but will verify tomorrow (PST)

@pshrosbree
Copy link
Author

@forki should the conversion for .sfproj files not also add an import for Paket.Restore.targets?

@forki
Copy link
Member

forki commented Jan 12, 2018

I assume it should yes. Are you using latest paket?

@pshrosbree
Copy link
Author

pshrosbree commented Jan 12, 2018

Well, I am on the correct version in my .paket, but perhaps somehow an older one was referenced. I'll try again. Putting together a repo for #2976 first.

@pshrosbree
Copy link
Author

pshrosbree commented Jan 12, 2018

@forki This is what paket 5.130.3 does to the .sfproj:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets=";ValidateMSBuildFiles">
  <Import Project="..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
  <Import Project="..\..\..\..\tools\build-dotnet\ServiceFabricPackage.targets" />
  <PropertyGroup Label="Globals">
    <ProjectGuid>e1296024-58b6-4e25-843e-b9faa9b07be6</ProjectGuid>
    <ProjectVersion>1.6</ProjectVersion>
    <MinToolsVersion>1.5</MinToolsVersion>
  </PropertyGroup>
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <None Include="ApplicationPackageRoot\ApplicationManifest.xml" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="ApplicationParameters\Local.1Node.xml" />
    <Content Include="PublishProfiles\Local.1Node.xml" />
  </ItemGroup>
  <ItemGroup>
    <None Include="ApplicationParameters\Local.5Node.xml" />
    <None Include="PublishProfiles\Local.5Node.xml" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Scripts\Deploy-FabricApplication.ps1" />
  </ItemGroup>
  <ItemGroup>
    <None Include="paket.references" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\svc\EventHubReader.Factory\EventHubReader.Factory.csproj" />
    <ProjectReference Include="..\..\svc\EventHubReader.Watchdog\EventHubReader.Watchdog.csproj" />
    <ProjectReference Include="..\..\svc\EventHubReader\EventHubReader.csproj" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
  <PropertyGroup>
    <ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath>
  </PropertyGroup>
  <Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" />
  <Import Project="..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
  <Target Name="ValidateMSBuildFiles">
    <Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" />
    <Error Condition="!Exists('..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\..\..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package" />
  </Target>
</Project>

It does not add an import for Paket.Restore.targets. If it is added, but the Microsoft.VisualStudio.Azure.Fabric.MSBuild is not in the packages folder, then msbuild /t:Restore fails.

Also, note that for .sfproj files the Microsoft.VisualStudio.Azure.Fabric.MSBuild will always need the version in the path, so maybe that can be included in the convert-from-nuget algorithm.

@forki
Copy link
Member

forki commented Jan 12, 2018

yes I it's not a dotnet (new project style) project so that is correct

@pshrosbree
Copy link
Author

pshrosbree commented Jan 12, 2018

OK, good.

Is there a way to get msbuild /t:Restore to succeed from a clean folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants