CZEMacLeod / MSBuild.SDK.SystemWeb

This MSBuild SDK is designed to allow for the easy creation and use of SDK (shortform) projects targeting ASP.NET 4.x using System.Web.
MIT License
151 stars 8 forks source link

WCF projects supported? #32

Closed techmantel closed 2 years ago

techmantel commented 2 years ago

Found this SDK when trying to migrate a WCF project to sdk-style csproj file format. Getting things to compile, but it complains about missing RunCommand element.

Is this scenario supported and I'm missing something or am I expecting too much 😅

techmantel commented 2 years ago

Found something similar like this here https://github.com/dotnet/sdk/issues/833#issuecomment-440228858

Seems like this works:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <OutputType>Library</OutputType>
    <OutputPath>bin\</OutputPath>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <RunCommand>$(MSBuildExtensionsPath64)\..\IIS Express\iisexpress</RunCommand>
    <RunArguments>/path:&quot;$(MSBuildProjectDirectory)&quot; /port:18082</RunArguments>
  </PropertyGroup>
  ...rest of file...
</Project>

At least it starts to load the app from global.asax.cs, so that's nice (still having some problems in the app so cannot get it to fully load, but that's unrelated to this issue)

CZEMacLeod commented 2 years ago

I'm no WCF expert, but yes it does support WCF pretty much out of the box. I've made a couple of tweaks to the SDK to support .svc files, and added an example. It doesn't use the ASP.NET Core SDK, or the legacy RunCommand - just the standard LaunchSettings.json. Please feel free to add documentation or update the sample to better reflect example usage.

For reference I took the empty template (remember to install the templates if you haven't already so they show up in VS) and pretty much followed the instructions in How to: Host a WCF Service in IIS

If you are running a 'self-hosted' variant of WCF (which doesn't appear to be the case since your example shows invoking IIS Express), then just create a console app and then change the target framework from net6 to net48.

techmantel commented 2 years ago

Very much appreciated! It was late during Friday evening and I was probably quite tired after a long week. Today I quickly found (thanks to your input and a refreshing weekend) that the launchSettings.json was actually there and started working once I changed the commandName value from Project to IISExpress instead.

Oh and for those looking for the sample, it's here 😊