为 Azure Function 编译 F# .NET Core 项目
Compile F# .NET Core project for Azure Function
我可以通过持续交付(通过 Github)将 C# 项目成功部署到 Azure Function 应用程序,并且自动编译并成功部署。这是 csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions"
Version="1.0.6" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
但是,如果我在解决方案中包含 F# 项目,我会收到以下错误消息:
Project "D:\home\site\repository\MyFunc\MyFunc.fsproj" on node 1 (default targets).
D:\Program Files (x86)\MSBuild-15.3.409.57025\MSBuild\Microsoft\VisualStudio\v15.0\FSharp\Microsoft.FSharp.NetSdk.props(3,3): error MSB4019: The imported project "D:\Program Files (x86)\Microsoft SDKs\F#.1\Framework\v4.0\Microsoft.FSharp.NetSdk.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. [D:\home\site\repository\MyFunc\MyFunc.fsproj]
Done Building Project "D:\home\site\repository\MyFunc\MyFunc.fsproj" (default targets) -- FAILED.
这是 fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="File.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
</Project>
有没有办法让 Azure 编译 F# 项目?
到目前为止,很遗憾,您不能,因为缺少所需的文件 Microsoft.FSharp.NetSdk.props
。部署脚本也不会削减它,因为该文件夹不可访问。但是,仍然可以在另一个环境中构建您的项目,然后进行部署。
您可以在 this article 中找到更多详细信息。
我可以通过持续交付(通过 Github)将 C# 项目成功部署到 Azure Function 应用程序,并且自动编译并成功部署。这是 csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions"
Version="1.0.6" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
但是,如果我在解决方案中包含 F# 项目,我会收到以下错误消息:
Project "D:\home\site\repository\MyFunc\MyFunc.fsproj" on node 1 (default targets). D:\Program Files (x86)\MSBuild-15.3.409.57025\MSBuild\Microsoft\VisualStudio\v15.0\FSharp\Microsoft.FSharp.NetSdk.props(3,3): error MSB4019: The imported project "D:\Program Files (x86)\Microsoft SDKs\F#.1\Framework\v4.0\Microsoft.FSharp.NetSdk.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. [D:\home\site\repository\MyFunc\MyFunc.fsproj] Done Building Project "D:\home\site\repository\MyFunc\MyFunc.fsproj" (default targets) -- FAILED.
这是 fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="File.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
</Project>
有没有办法让 Azure 编译 F# 项目?
到目前为止,很遗憾,您不能,因为缺少所需的文件 Microsoft.FSharp.NetSdk.props
。部署脚本也不会削减它,因为该文件夹不可访问。但是,仍然可以在另一个环境中构建您的项目,然后进行部署。
您可以在 this article 中找到更多详细信息。