0
votes

I am unable to publish my Azure Functions (v1) Project after upgraded to VisualStudio 15.7.0 Preview 6.0 I get this error when click Publish button

C:\Program Files\dotnet\sdk\2.1.200-preview-007597\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error : Assets file 'C:\Users\tonyv\source\repos\SistemaMulti\WebAPI\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v4.6.1/win'. Ensure you have restored this project for TargetFrameworks 'net461' Maybe you also need to include 'win' on RuntimeIdentifiers of yout project. [C:\Users\tonyv\source\repos\SistemaMulti\WebAPI\WebAPI.csproj]

VS 2017

My .csproj is:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="MercadoPago\Pessoa.cs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="MercadoPago\" />
  </ItemGroup>
</Project>

How to fix this?

2
Can you please check if you have the following entry in the pubxml (under Properties\Publish Profiles\<profilename>.pubxml) <RuntimeIdentifier>win</RuntimeIdentifier>. If so, please remove this entry and try publishing again.vijayrkn
I did these steps, it had the <RuntimeIdentifier>win</RuntimeIdentifier>, then I removed it, Published and I can confirm it worked OK now! Put this as answer so I can mark acceptTony

2 Answers

2
votes

The issue is that the following property is getting set in the publish profile (under Properties\Publish Profiles\<profilename>.pubxml)

<RuntimeIdentifier>win</RuntimeIdentifier>

Removing this property from the publishprofile should fix the issue.

0
votes

There is a github thread for the same issue - https://github.com/Azure/Azure-Functions/issues/571

The workaround recommended there is: Update this line in Properties\PublishProfiles\.pubxml (Remove the space in Any CPU). <LastUsedPlatform>AnyCPU</LastUsedPlatform>

(Updating the profile from profile settings UI may re-add the space. Please remove it after any profile modification).