Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

Build 1.1.0-preview4 version of dotnet-publish-iis #299

Merged
merged 2 commits into from
Nov 10, 2016

Conversation

natemcmaster
Copy link
Contributor

dotnet-publish-iis. Identical to 1.0.0-preview4 except with support for .NET Core 1.1 and FTS dependencies.

This is like a cli dandelion we've tried to kill it many times, but it keeps popping up again because reasons.

But for real, this should be the final final version of this tool as it has been deprecated in favor of MSBuild targets in Microsoft.NET.Sdk.Web.

cc @muratg

@@ -0,0 +1,39 @@
{
"version": "1.1.0-preview4-final",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we plan on keeping it around in dev 1.1.0-* should suffice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't intend to. When I merge back to dev, this source code won't be making the trip back into the dev branch

@natemcmaster natemcmaster merged commit f2cbf9f into rel/1.1.0 Nov 10, 2016
@natemcmaster natemcmaster deleted the namc/one-last-time branch November 10, 2016 18:42
natemcmaster pushed a commit to aspnet/Coherence that referenced this pull request Nov 10, 2016
@guardrex
Copy link
Contributor

guardrex commented Nov 17, 2016

@natemcmaster @moozzyk

as it has been deprecated in favor of MSBuild targets in Microsoft.NET.Sdk.Web.

Is there more info on getting publish-iis functionality under MSBuild?

I just migrated a project.json-based proj to MSBuild/csproj, and I'd like to preview the publish-iis bits (i.e., web.config generation/modification) for doc updates to Publish to IIS.

publish-iis doesn't play well in the new world based on its dependency on the project.json file ...

PostpublishScript:
         guardrex-publish-iis --publish-folder <PATH>\testselfcontained\bin\Release\netcoreapp1.1\ --framework .NETCoreApp,Version=v1.1
         Configuring the following project for use with IIS: '<PATH>\testselfcontained\bin\Release\netcoreapp1.1\'
         No web.config found. Creating '<PATH>\testselfcontained\bin\Release\netcoreapp1.1\web.config'
         Could not find file '<PATH>\testselfcontained\project.json'.

Otherwise, this is no biggie of course ... I can simply go back to a handmade web.config and ...

<Content Include="web.config">
  <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>

@natemcmaster
Copy link
Contributor Author

@guardrex this PR was meant to produce a version of dotnet-publish-iis for .NET Core 1.1 and project.json. As I stated earlier, the tool is not meant to work in MSBuild.

I'd like to preview the publish-iis bits

You should make sure to reference the Microsoft.NET.Sdk.Web package. This should include targets to transform the web.config as publish-iis did. cref https://www.nuget.org/packages/Microsoft.NET.Sdk.Web/1.0.0-alpha-20161104-2-112

@vijayrkn
Copy link

@guardrex
The only issue we are aware of is during the migration, post publish script section is added to the csproj. If you remove this manually web.config transform should happen automatically. https://github.com/dotnet/cli/issues/4612

Make sure you have reference to web sdk version >=20161104-2-112.

Both dotnet publish & publish from VS should handle the transform. If this is not happening, can you share the csproj?

@guardrex
Copy link
Contributor

Yes, I pulled that post publish section and was just copying a handmade web.config last night; however, I'm back to receiving an exception that I was getting early last night ....

"<PATH>\testselfcontained\testselfcontained.csproj" (Publish target) (1) ->
  (_CopyResolvedFilesToPublishPreserveNewest target) -> 
  C:\Users\<USER>\.nuget\packages\microsoft.net.sdk\1.0.0-alpha-20161104-2\build\
    Microsoft.NET.Publish.targets(98,5): error MSB3094: "DestinationFiles" refers to 1 item(s),
    and "SourceFiles" refers to 2 item(s). They must have the same number of items. 
    [<PATH>\testselfcontained\testselfcontained.csproj]

☝️ that was happening early in the evening ... I screwed around with installed tooling ... I may have pulled down 1.0.0-preview4-004079 from the CLI repo, then went back to 1.0.0-preview3-004056, nuked package cache, nuked bin and obj ... those types of things ... then it ✨ magically ✨ started to work and produce published output. This morning, I'm back (for no obvious reason) to getting the exception above.

The csproj is at: https://gist.github.com/GuardRex/58bb9e17a9b372c7bfcd3f79043365ab

Just for the moment, while I get past this error MSB3094 problem, I just have ...

<Content Include="web.config">
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>

at the moment.

I'll setup the targets for web.config transform as soon as I get publish working again.

@vijayrkn
Copy link

  • You don't need to add this:

    <Content Include="wwwroot\**\*">

      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>

    </Content>

    <Content Include="Views\**\*">

      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>

    </Content>

    <Content Include="Logs\*" Exclude="Logs\*.log">

      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>

    </Content>

    <Content Include="web.config">

      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>

    </Content>

This is already added as part of : https://github.com/aspnet/websdk/blob/dev/src/Web/Microsoft.NET.Sdk.Web.ProjectSystem.Targets/netstandard1.0/Microsoft.NET.Sdk.Web.ProjectSystem.targets

  • You can remove this. NET.Web.SDK will bring the matching NET.Sdk.
    <PackageReference Include="Microsoft.NET.Sdk">

      <Version>1.0.0-*</Version>

      <PrivateAssets>All</PrivateAssets>

    </PackageReference>
  • You can update the version of this to 1.0.0-alpha-20161104-2-112 which has the right targets to perform web.config transform automatically.
<PackageReference Include="Microsoft.NET.Sdk.Web">

      <Version>1.0.0-alpha-20161104-2-112Version>

      <PrivateAssets>All</PrivateAssets>

    </PackageReference>

@guardrex
Copy link
Contributor

😄

Yes, it's back to publishing now. Yes, I can get a tooling-generated web.config or a modified web.config when I include one in the project.

https://github.com/aspnet/websdk/blob/dev/src/Web/Microsoft.NET.Sdk.Web.ProjectSystem.Targets/netstandard1.0/Microsoft.NET.Sdk.Web.ProjectSystem.targets

That's an internal GH repo, but I did remove those entries.

I removed Microsoft.NET.Sdk and pegged the version on the Microsoft.NET.Sdk.Web to 1.0.0-alpha-20161104-2-112.

Resultant working csproj: https://gist.github.com/GuardRex/58bb9e17a9b372c7bfcd3f79043365ab

A couple of notes on the dotnet migrate experience ...

  • You know about the bad post-publish section on migration of the old publish-iis tooling.
  • You know that Razor precomp tooling is WIP, but dotnet migration tried to setup a post-publish script for that, too. Also, the Razor precomp package names changed, but the migration tooling didn't change the package names automatically.
  • The Content Include's that you had me remove came in via the dotnet migration tooling, and that was what was (apparently) causing my "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). exception.
  • Somehow in the process of getting tooling installed last night, I ended up pulling down (probably via the SDK installer in the .NET Blog post on the 1.1 release) an x86 version of dotnet.exe that ended up at c:\Program Files(x86)\dotnet, and it ended up on the PATH before my entry for the 1.0.0-preview4-004079 tooling that I had installed earlier from the dotnet/CLI repo. I had to manually remove the x86 version from the PATH to get my preview4 tooling back on the command line. 👈 It's very likely that I made a mistake when installing the .NET Core 1.1 SDK/tooling.

Thanks @vijayrkn and @natemcmaster. I'm good. 👍 I'm just on stand-by for the Razor precomp bits to proceed migrating larger projects.

@nil4
Copy link

nil4 commented Dec 14, 2016

@vijayrkn @guardrex Using either VS 2017 RC "update" and dotnet 1.0.0-preview4-004233, I cannot find how to enable Web.config transformations at publish time. Do you have any guidance on how to achieve this (e.g. transform Web.config using Web.Release.config XDT) with the MSBuild-based tooling?

@guardrex
Copy link
Contributor

I don't have any new information. These issues haven't been touched for a while ...

aspnet/Tooling#252
aspnet/Tooling#841
aspnet/Tooling#780
#146
dotnet/aspnetcore#1485

@nil4
Copy link

nil4 commented Dec 14, 2016

Thank you, @guardrex! Sadly this matches what I am seeing. I was hopeful when I discovered Microsoft.NET.Sdk.Publish.TransformFiles.targets and it's _WebConfigTransform target, but it was short-lived enthusiasm: it only adds the ANCM reference, or some Azure-specific changes that are not relevant for us.

@davidfowl
Copy link
Member

@nil4 what things were you looking to transform in the web.config file?

@nil4
Copy link

nil4 commented Dec 14, 2016

Anything under <system.webServer> that differs between local development, and the multiple deployment environments we use. This includes IIS URL rewrite rules, IIS httpProtocol limits (e.g. max request/upload sizes) and custom headers (e.g. removing X-Powered-By and friends). But most importantly, authentication settings; e.g. Negotiate/Kerberos is required by our production infrastructure, but not supported by IIS Express.

I was able to fill this gap in earlier versions by porting the CLI tool for XDT transforms. With the change to MSBuild, the CLI tool no longer works.

MSBuild historically had support for XDT transforms for years using the XmlTransform task (Sayed has a whole blog series on it). Also aspnet/Tooling#780 seemed to indicate XDT transforms are on the roadmap. I am looking for guidance on transforming Web.config at publish time with the new tooling.

@benzhi2011
Copy link

benzhi2011 commented Dec 15, 2016

Great @nil4! I have been waiting for this for a while, what is the expected release date for this update?

@nil4
Copy link

nil4 commented Dec 15, 2016

That's the question I also have for @davidfowl or @sayedihashimi

@nil4
Copy link

nil4 commented Dec 26, 2016

While waiting for the official solution, I updated dotnet-transform-xdt with MSBuild/csproj support and added a couple of samples: https://github.com/nil4/xdt-samples

@benzhi2011
Copy link

@nil4 Thank you for working on this in Christmas

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

Successfully merging this pull request may close these issues.

9 participants