Changing the name of the output assembly and packa

2019-04-18 18:05发布

问题:

I have a project which exists in a directory named Oracle and I would like the artifacts created to be called MyCompany.MyApp.Oracle instead of Oracle, what are my options for changing the output assembly name and nuget package name outside of changing the name of the directory?

  • I currently have a MyCompany.MyApp.Oracle.xproj next to my project.json file
  • I've also tried setting <AssemblyName>MyCompany.MyApp.Oracle</AssemblyName> in the xproj file but that didn't work
  • I've also tried setting {"id":"MyCompany.MyApp.Oracle"} in project.json and still no luck

回答1:

Based on comment of @Victor Hurdugaci

"buildOptions": {
    "outputName": "Some.Specific.Assembly.Name"
},

You need to put it inside project.json file. It will produce output with name: Some.Specific.Assembly.Name.dll



回答2:

Later edit: this answer was applicable to the pre-dotnet releases (dnx). Now it's possible to change the package name.

Old answer: The only way to change the package name is by changing the folder name.



回答3:

From .NET Core 1.1 on, which uses csproj instead of package.json, you should use the <AssemblyName> configuration.

Example of x.csproj:

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

  <PropertyGroup>
    <AssemblyName>Name your assembly here</AssemblyName>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

</Project>


标签: dnx .net-core