问题
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 "$(PublishOutputPath)""
WorkingDirectory="$(MSBuildProjectDirectory)" />
<PropertyGroup>
<DnuCommand>"$(SDKToolingDirectory)\bin\dnu.cmd" 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) "$(KPackWorkingDirectory)" --out "$(PublishOutputPathNoTrailingSlash)" --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