我们希望在没有安装VS的系统上构建dotnet项目。我们安装了最新的4.6.2 dotnet开发工具和sdk以及msbuild-tools 12.0。
未安装Visual Studio。
我们有一个nuget包,它实现了一个额外的构建步骤。它可以在VS Express中运行,也可以在msbuild命令行上安装VS Express,但不安装任何VS.
从服务器下载软件包并将其放入解决方案的packages文件夹中。
然而,包中的自定义构建步骤不会在构建时执行 - 为什么? 我们缺少什么?
这是nuget包:
\Package.nuspec
\build\nugetPostbuild.targets
\script\createPackageAndUpload.cmd
目标文件是这样的:
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="postbuildPackNuGetTarget" AfterTargets="Build">
<Message Importance="high" Text="Message from MyNuGetCustomTarget. Configuration: $(MSBuildThisFileDirectory)..\nuget_postbuild_script\createPackageAndUpload.cmd $(ProjectDir) $(ProjectFileName) $(ConfigurationName) $(TargetDir)" />
<Exec Command="$(MSBuildThisFileDirectory)..\nuget_postbuild_script\createPackageAndUpload.cmd $(ProjectDir) $(ProjectFileName) $(ConfigurationName) $(TargetDir)" />
</Target>
</Project>
规范是这样的:
<?xml version="1.0"?>
<package >
<metadata>
<id>nugetPostbuild</id>
<version>1.0.3</version>
<authors>thewindowsuser</authors>
<owners>thewindowsuser</owners>
<projectUrl>http://...</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>bla ...</description>
<releaseNotes>http://...</releaseNotes>
<copyright>Copyright ...</copyright>
<tags>some tags here</tags>
</metadata>
<files>
<file src="script\**" target="nuget_postbuild_script" />
<file src="build\**" target="build" />
</files>
</package>
更新:
在包工作的.csproj文件中,我找到了以下导入:
<Import Project="..\packages\nugetPostbuild.1.0.3\build\nugetPostbuild.targets" Condition="Exists('..\packages\nugetPostbuild.1.0.3\build\nugetPostbuild.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> ... error text removed ...</PropertyGroup>
<Error Condition="!Exists('..\packages\nugetPostbuild.1.0.3\build\nugetPostbuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\nugetPostbuild.1.0.3\build\nugetPostbuild.targets'))" />
</Target>
这些是由nuget还是由Visual Studio添加的?我希望它们能从nuget添加,但这似乎不会发生。