Skip to content

pj to csproj mapping - #1581

Merged
mairaw merged 5 commits into
dotnet:masterfrom
mairaw:blogpost
Feb 25, 2017
Merged

mairaw merged 5 commits into
dotnet:masterfrom
mairaw:blogpost

Conversation

@mairaw

@mairaw mairaw commented Feb 22, 2017

Copy link
Copy Markdown
Contributor

@natemcmaster natemcmaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I found a few things that are outdated, and some typos to fix (guess I need to proof-read my own blog posts better).

It would be good to also have someone from the SDK team help verify this. cc @BlackDwarf or someone else.

.NET Core project using the new `Microsoft.NET.Sdk` metapackage.

```xml
<Project Sdk="Microsoft.NET.Sdk">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It may be worth noting that Web projects should use Microsoft.NET.Sdk.Web here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added.

```

### Standalone apps (self-contained deployment)
In project.json, defining a `runtimes` section mean the app was standalone during

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Grammar: mean => means.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you push updates to the PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@natemcmaster I will as soon as I finish working on all your feedback. I'll let you know.

"requireLicenseAcceptance": false,
"repository": {
"type": "git",
"url": "https://github.com/natemcmaster/natemcmaster.github.io"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we change these examples to something more official, like https://github.com/dotnet?


```xml
<PropertyGroup>
<Summary>A bundle of cats</Summary>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have since learned that Summary is not supported by NuGet. It should be Title instead. cref NuGet/Home#4150

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@natemcmaster actually, summary seems to migrate to the Description field. I'll download the latest CLI to make sure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

scratch what I said. the value actually didn't migrate it to any field. should it? @natemcmaster

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Scratch what I said too. Title isn't what we want. Basically, "Summary" is not supported (yet). This should be added to "Description".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm confused. The description property is migrated to Description.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To clarify, NuGet doesn't support <Summary>. PJ's packOptions/summary doesn't have an equivalent in csproj.

csproj added a new field, <Title>, but this is not the same as packOptions/summary.

</PropertyGroup>
```

## packOptions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be good to verify this with @rrelyea and/or @rohit21agrawal

```

```xml
<PropertyGroup>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should also add PackageId. It defaults to the value of AssemblyName.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can mention PackageId but it doesn't map to anything in project.json, correct? I've also migrated a test project that had an outputName value and so PackageId and AssemblyName had different values. So it seems that PackageId defaults to the folder name. Who can confirm that @natemcmaster?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PackageId maps to "name" in project.json. PJ => csproj isn't a one-to-one mapping. "name" maps to both PackageId and AssemblyName.

@mairaw mairaw Feb 23, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's not the behavior I'm seeing with the migration @natemcmaster. This is what I see:
name -> not supported
buildOptions\outputName -> AssemblyName
title -> AssemblyTitle
PackageID is by default based on the directory name and it doesn't come from anywhere in pj

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, that's intended migration behavior. PJ's "name" setting was always a bit buggy. Setting "name" different from directory name never worked completely. 99.9% of PJ project's have folder name set to PackageId.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but what exactly do you want me to say? PackageId and AssemblyName can be different if buildOptions\outputName was defined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In project.json, "name" was used for the assembly name as well as the name of the package. In MSBuild, these default to the name of the csproj file. Assembly name can be overridden with <AssemblyName> and package name can be overridden with <PackageId>.

}
```

All settings in this group should be placed in the project folder into a file called

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This section is outdated now. Here's the latest on configuring runtime options:


<PropertyGroup>
  <ServerGarbageCollection>true</ServerGarbageCollection>
  <ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
  <RetainVMGarbageCollection>true</RetainVMGarbageCollection>
  <!-- I'm not suggesting these settings...just showing usage ;) -->
  <ThreadPoolMinThreads>10</ThreadPoolMinThreads>
  <ThreadPoolMaxThreads>100</ThreadPoolMaxThreads>
</ProeprtyGroup>

Tip: If you are working on a web project, specifying <Project Sdk="Microsoft.NET.Sdk.Web">
will automatically default ServerGarbageCollection to true.

See CoreCLR configuration
for information on these settings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added all the knobs into my test project.json file:

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true,
      "System.GC.Concurrent": true,
      "System.GC.RetainVM": true,
      "System.Threading.ThreadPool.MinThreads": 4,
      "System.Threading.ThreadPool.MaxThreads": 25
    }
  },

and the only one that got migrated was <ServerGarbageCollection>true</ServerGarbageCollection>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's probably a limitation of dotnet-migrate, but these options are definitely supported. cref dotnet/sdk#746

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @natemcmaster. I'll open an issue.

Package layout inside the .nupkg can be modified with `PackagePath="path"`.

Except for `Content`, most item groups require explicitly adding `Pack="true"` to
be included in the package. By default, this will be but in the 'content' folder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo: but => put

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a sentence I was going to ask you about. Thanks! Fixed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Might be worth mentioning that IncludeContentInPack, which is true by default, is what makes all items of type Content to be added to the nupkg by default. This behavior can be overridden by setting it to false.

```xml
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
<PackageReference Include="MSTest.TestAdapter" Version="1.0.0-*" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The latest is version 1.1.12

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
<PackageReference Include="MSTest.TestAdapter" Version="1.0.0-*" />
<PackageReference Include="MSTest.TestFramework" Version="1.0.0-*" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The latest of this one is 1.1.11

@mairaw mairaw added WIP and removed WIP labels Feb 23, 2017
@mairaw
mairaw requested a review from thesmithee February 24, 2017 02:41
@mairaw

mairaw commented Feb 24, 2017 •

Copy link
Copy Markdown
Contributor Author

I think I took care of all the feedback so far. Thanks for the comments! Please take a look and see if it's good to merge. I've also added the behavior of the migration of the .NET Standard metapackage to the <NetStandardImplicitPackageVersion> property that wasn't part of the original post.

I've opened issue https://github.com/dotnet/cli/issues/5827 for the runtimeOptions behavior.

/cc @natemcmaster @rohit21agrawal @BlackDwarf

@natemcmaster natemcmaster left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One minor change (see comment below). Otherwise looks good. :shipit:


```xml
<PropertyGroup>
<Title>numl is a machine learning library intended to ease the use of using standard modeling techniques for both prediction and clustering.</Title>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be <Description>, not <Title>...sorry if my comments cause confusion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, your comments didn't cause confusion. It was a leftover change I forgot to edit. Thanks for your review @natemcmaster!

@mairaw
mairaw merged commit 166dc5d into dotnet:master Feb 25, 2017
@mairaw
mairaw deleted the blogpost branch February 25, 2017 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants