Visual Studio 2015 (latest update) publish function does not compile ASP.NET Core RC1 sources

女生的网名这么多〃 提交于 2020-01-04 02:09:07

问题


I begun working on a new ASP.NET Core RC1 project months ago, and Publishing with Visual Studio 2015, was producing a folder tree ready to deploy without the project C# sources (because it was compiling it in assemblies placed into the folder tree).

Now that I've upgraded the Visual Studio (only the VS, not the project that remains in 1.0.0-rc1-final) with latest updates (circa May, 19 2016): "Microsoft .NET Core 1.0.0 RC2 - VS 2015 Tooling Preview 1", "Microsoft .NET Core 1.0.0 RC2 - SDK Preview 1 (x64)", "Microsoft ASP.NET 5 RC1 Update 1" (1.0.11123.0) and "Microsoft ASP.NET 5 RC1 Update 1" (1.0.20204.0)

it looks that the new Publish functionality of latest VS2015 updates, does not compile anymore the sources, instead it places into the Publish folder tree the project c# sources.

Can someone please indicate me how to force VS Publish functionality to compile again instead copying c# sources into the Publish Folders?


回答1:


we removed this option ("Compile source files into NuGet packages") from the Publish dialog in rc2 tooling because this is not applicable for dotnet projects any more.

In order to publish an rc1 project with the –no-source option from VS, you can add this target to the pubxml (target needs to be inside the project and outside the propertygroup).

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
<all your existing property group values>
  </PropertyGroup>

     <Target Name="DnuNoSourcePublish" AfterTargets="GatherAllFilesToPublish" Condition=" '$(CompileSource)' == 'true' ">
        <Exec
          Condition="Exists('$(PublishOutputPath)') and '$(PublishOutputPath)'!='' "
          Command="rmdir /S /Q &quot;$(PublishOutputPath)&quot;"
          WorkingDirectory="$(MSBuildProjectDirectory)" />

        <PropertyGroup>
          <DnuCommand>&quot;$(SDKToolingDirectory)\bin\dnu.cmd&quot; publish</DnuCommand>
          <RuntimeArgument Condition=" '$(FinalPublishVersion)' != '' " >--runtime $(FinalPublishVersion)</RuntimeArgument>
          <WwwRootArgument Condition=" '$(WebRoot)' != '' " >--wwwroot $(WebRoot)</WwwRootArgument>
          <WwwRootOutArgument Condition=" '$(WwwRootOut)' != '' " >--wwwroot-out $(WwwRootOut)</WwwRootOutArgument>
          <IISCommandArgument Condition =" '$(IISCommand)' != ''">--iis-command $(IISCommand)</IISCommandArgument>
          <NoSourceArgument Condition=" '$(CompileSource)' == 'true' ">--no-source</NoSourceArgument>
          <NativeArgument Condition="'$(NativeFlag)' == 'true'">--native</NativeArgument>
          <IncludeSymbolsArgument Condition=" '$(IncludeSymbolsFlag)' == 'true'">--include-symbols</IncludeSymbolsArgument>
          <QuietArgument Condition=" '$(QuietFlag)' == 'true'">--quiet</QuietArgument>
        </PropertyGroup>

        <Exec
          Command="SET PATH=$(ExternalToolsPath);@(DnuPublishEnvironmentVariables)
          $(DnuCommand) &quot;$(KPackWorkingDirectory)&quot; --out &quot;$(PublishOutputPathNoTrailingSlash)&quot; --configuration $(PublishConfiguration) $(RuntimeArgument) $(WwwRootArgument) $(WwwRootOutArgument) $(IISCommandArgument) $(NoSourceArgument) $(QuietArgument) $(NativeArgument) $(IncludeSymbolsArgument)"
          WorkingDirectory="$(KPackWorkingDirectory)"/>
      </Target>
</Project>

Make sure your property group has this property set

 <CompileSource>true</CompileSource>



回答2:


Looking how VS was publishing prior to the RC2 updates, I noticed the two:

C:\Users\(user)\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnu.cmd publish "(destinationFolder)" --out "C:\Users\(user)\AppData\Local\Temp\PublishTemp\(tempFolder)" --configuration Debug --no-source --runtime dnx-clr-win-x86.1.0.0-rc1-update1 --wwwroot "wwwroot" --wwwroot-out "wwwroot" --iis-command "web" --quiet

"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:contentPath='C:\Users\(user)\AppData\Local\Temp\PublishTemp\(tempFolder)\' -dest:contentPath='(destinationFolder)' -verb:sync -retryAttempts:2 -disablerule:BackupRule

so, deleting the two folders: (destinationFolder) and C:\Users\(user)\AppData\Local\Temp\PublishTemp\(tempFolder), and running the two commands above "by hands" in command prompt, I obtained the wanted result



来源:https://stackoverflow.com/questions/37397315/visual-studio-2015-latest-update-publish-function-does-not-compile-asp-net-cor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!