ASP .Net Core 3.1使用自定义名称构建到客户文件夹,而不是netcoreapp3.1

时间:2020-04-09 13:35:55

标签: asp.net-core asp.net-core-3.1

我为现有项目解决方案开发了一个类库。并且它构建成功。

这是一个nop Commerce插件,我需要使用项目名称将其构建到特定文件夹中,然后由插件管理器按名称搜索我的插件并将其加载到页面中进行安装。

当我构建它时,它将构建到名为“ netcoreapp3.1”的文件夹。但是我需要将其构建到自定义文件夹中。

这是我的.proj文件

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <Copyright>Copyright © Company, Ltd</Copyright>
    <Company>Company, Ltd</Company>
    <Authors>Isanka Thalagala</Authors>
    <PackageLicenseUrl></PackageLicenseUrl>
    <PackageProjectUrl>http://www.nopcommerce.com/</PackageProjectUrl>
    <RepositoryUrl>https://github.com/nopSolutions/nopCommerce</RepositoryUrl>
    <RepositoryType>Git</RepositoryType>
    <OutputPath>..\..\Presentation\Nop.Web\Plugins\Image.Upload.Azure</OutputPath>
    <OutDir>$(OutputPath)</OutDir>
    <!--Set this parameter to true to get the dlls copied from the NuGet cache to the output of your project.
    You need to set this parameter to true if your plugin has a nuget package 
    to ensure that the dlls copied from the NuGet cache to the output of your project-->
    <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
  </PropertyGroup>


  <!-- This target execute after "Build" target -->
  <Target Name="NopTarget" AfterTargets="Build">
    <!-- Delete unnecessary libraries from plugins path -->
    <MSBuild Projects="@(ClearPluginAssemblies)" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
  </Target>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <OutputPath>D:\LabFriend\JohnMorrisCore\API\Presentation\Nop.Web\Plugins\Image.Upload.Azure</OutputPath>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <OutputPath>D:\LabFriend\JohnMorrisCore\API\Presentation\Nop.Web\Plugins\Image.Upload.Azure</OutputPath>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="plugin.json" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="ImageResizer" Version="4.2.5" />
    <PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.3" />
    <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\..\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
    <ProjectReference Include="..\JohnMorris.Plugin.Core\JohnMorris.Plugin.Core.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="logo.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="plugin.json" />
    <Content Update="plugin.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

</Project>

这是设置屏幕

enter image description here

2 个答案:

答案 0 :(得分:0)

我将其降级为.net core 2.2。现在可以使用自定义名称

进行构建

答案 1 :(得分:0)

您可以在 .csproj 中设置以下内容以禁用此行为。

<PropertyGroup>
  <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>