Azure / azure-webjobs-sdk

Azure WebJobs SDK
MIT License
737 stars 358 forks source link

WebJob as .NET Standard/Core project will not make valid zip package on VSTS #1635

Open JSCProjects opened 6 years ago

JSCProjects commented 6 years ago

We are using the new csproj definition(.NET Standard/.NET Core) for our new assemblies and when we try to create a package from VSTS which we will use to deploy our WebJob with VSTS to a website.

Repro steps

Provide the steps required to reproduce the problem

Prereq:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\$(BuildConfiguration)"

Repro

  1. Create Console App (.NET Core)
  2. Edit newly created csproj file
  3. Change targetframework to net461
  4. Reference Microsoft.Azure.WebJobs Version="2.1.0"
  5. Microsoft.Web.WebJobs.Publish Version="1.1.0"
  6. Push changes to VSTS
  7. Trigger build

Expected behavior

A zip file with all the assemblies of the WebJob

Actual behavior

With the old CSPRoj versions of VS2017 I get a zip with all the assemblies of the WebJob. With .NET Standard/Core project the zip is empty :-(

Known workarounds

Change from .NET Standard/Core projecttype to Azure WebJob (.NET Framework)

paulbatum commented 6 years ago

@vijayrkn do you have any context on this? i assume the issue is related to either the publish nuget or to VSTS itself..

vijayrkn commented 6 years ago

@JSCProjects - Here is an example on what all properties are expected to create a WebDeploy package with new Sdk style projects https://github.com/vijayrkn/ASPNetPublishSamples/blob/bff9f78d796668dc07d5e28a8b93531caade839c/Publish.cmd#L170

JSCProjects commented 6 years ago

@vijayrkn sorry for the late response. Your suggested solution still doesn't give me a valid webjob zip with VSTS

image

Below my project file

<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <ApplicationIcon />
    <OutputType>Exe</OutputType>
    <StartupObject />
    <AssemblyName>Fudura.Far.Facturatie.WebJob</AssemblyName>
    <RootNamespace>Fudura.Far.Facturatie.WebJob</RootNamespace>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <CodeAnalysisRuleSet>WebJob-1.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <CodeAnalysisRuleSet>WebJob-1.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="REMOVED.REMOVED.Common" Version="1.4.0" />
    <PackageReference Include="REMOVED.REMOVED.Common.Ninject.WebJobs" Version="1.0.1" />
    <PackageReference Include="REMOVED.REMOVED.Common.NServiceBus" Version="3.0.6" />
    <PackageReference Include="REMOVED.REMOVED.Common.NServiceBus.Metrics.ServiceControl" Version="1.0.2" />
    <PackageReference Include="REMOVED.Shared" Version="2.0.0" />
    <PackageReference Include="REMOVED.Shared.BlobStorage" Version="3.1.0" />
    <PackageReference Include="logentries.nlog" Version="2.6.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs" Version="2.1.0" />
    <PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.0.61" />
    <PackageReference Include="Microsoft.Web.WebJobs.Publish" Version="1.1.0" />
    <PackageReference Include="Microsoft.WindowsAzure.ConfigurationManager" Version="3.2.3" />
    <PackageReference Include="Ninject" Version="3.3.4" />
    <PackageReference Include="Ninject.Extensions.ContextPreservation" Version="3.3.1" />
    <PackageReference Include="Ninject.Extensions.NamedScope" Version="3.3.0" />
    <PackageReference Include="NLog" Version="4.4.13" />
    <PackageReference Include="NServiceBus.Azure.Transports.WindowsAzureServiceBus" Version="7.2.11" />
    <PackageReference Include="NServiceBus.Heartbeat" Version="2.0.0" />
    <PackageReference Include="NServiceBus.Ninject" Version="6.0.1" />
    <PackageReference Include="NServiceBus.NLog" Version="2.0.0" />
    <PackageReference Include="SonarAnalyzer.CSharp" Version="6.8.2.4717" />
    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Handlers\Handlers.csproj" />
    <ProjectReference Include="..\Model\Model.csproj" />
    <ProjectReference Include="..\Messages\Messages.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="app.config">
      <TransformOnBuild>true</TransformOnBuild>
    </None>
    <None Update="app.Debug.config">
      <IsTransformFile>True</IsTransformFile>
    </None>
    <None Update="app.Release.config">
      <IsTransformFile>True</IsTransformFile>
    </None>
    <None Update="Settings.job">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>
vijayrkn commented 6 years ago

Are these properties getting passed? https://github.com/vijayrkn/ASPNetPublishSamples/blob/bff9f78d796668dc07d5e28a8b93531caade839c/Publish.cmd#L116-L119

I don't see them in the csproj or in the screenshot.

JSCProjects commented 6 years ago

But how can I set these properties in the csproj?

vijayrkn commented 6 years ago

You can set them as properties similar to <AssemblyName>Fudura.Far.Facturatie.WebJob</AssemblyName>

for e.g the following properties under PropertiesGroup:

<PropertyGroup>
    <IsWebJobProject>true</IsWebJobProject>
    <WebJobName>$(AssemblyName)</WebJobName>
    <WebJobType>Continuous</WebJobType>
</PropertyGroup>
JSCProjects commented 6 years ago

Thanx that will do the job!

JSCProjects commented 5 years ago

I've upgraded to version 3.0 and now I'm getting almost empty zips again.

spr0ut commented 5 years ago

You can set them as properties similar to <AssemblyName>Fudura.Far.Facturatie.WebJob</AssemblyName>

for e.g the following properties under PropertiesGroup:

<PropertyGroup>
    <IsWebJobProject>true</IsWebJobProject>
    <WebJobName>$(AssemblyName)</WebJobName>
    <WebJobType>Continuous</WebJobType>
</PropertyGroup>

This is missing from VS 2019 WebJob templates - a frustrating experience as it will publish via VS direct to Azure correctly but when using msbuild to package, it produces an empty .zip file.

agtenr commented 5 years ago

Any news on this. I am experiencing the same issue

mohaemen commented 4 years ago

I have the same issue too

unowiz commented 4 years ago

I have the same issue. I have created a new project using Vs2019 Webjobs .NET framework template. There is no issue publishing from VS 2019 but when trying to do build on azure devops using msbuild or vsbuild tasks, it says succeeded but the webjobs zip contents would not have the dlls

paulbatum commented 4 years ago

So to clarify, are the above workaround steps (add the webjobs properties to your project file) not working? The templates should be updated to include these proeprties in VS 16.5 preview 2 and newer, but if these manual steps are not working for you then there might be another issue that we need to investigate.

unowiz commented 4 years ago

Hey @paulbatum, thanks, Works. I presumed the workaround didn't work earlier but that was for different reason.

paulbatum commented 4 years ago

@unowiz great, thanks letting me know. I will leave this issue open until the VS update is available.

JSCProjects commented 4 years ago

Still facing troubles generating a valid zip. I’m using dotnet.exe instead of msbuild.exe