解决方案目录包含外推和项目目录。在project.csproj文件中,我们在带有相对路径的间隙中有DLL的引用。Extradlls目录中的DLL始终可用。
<Reference Include="xyx, Version=7.3.0.0, Culture=neutral, PublicKeyToken=<sometoken>">
<SpecificVersion>False</SpecificVersion>
<HintPath>..ExtraDllsA.dll</HintPath>
</Reference>
<Reference Include="xyz, Version=7.4.0.0, Culture=neutral, PublicKeyToken=<sometoken>">
<SpecificVersion>False</SpecificVersion>
<HintPath>..ExtraDllsB.dll</HintPath>
<Private>True</Private>
</Reference>
使用以下批处理文件发布Web项目。但它失败了以下提到的详细信息。
SET MSBUILD_PATH="C:Program Files (x86)Microsoft Visual Studio2019ProfessionalMSBuildCurrent\Bin"
SET PUBLISH_DIRECTORY="C:publishProjectA"
SET PROJECT_DIR="C:SolutionDirProjectDir"
SET PROJECT="C:SolutionDirProjectDirProject.csproj"
cd %PROJECT_DIR%
%MSBUILD_PATH%MSBuild.exe %PROJECT% /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=%PUBLISH_DIRECTORY%
PreBuildEvent:
copy "..ExtraDllsA.dll" "C:SolutionDirProjectDirbin"
copy "..ExtraDllsB.dll" "C:SolutionDirProjectDirbin"
The system cannot find the path specified.
The system cannot find the path specified.
C:Program Files (x86)Microsoft Visual Studio2019ProfessionalMSBuildCurrentBinMicrosoft.Common.CurrentVersion.targets(1328,5): error MSB3073: copy "..ExtraDllsA.dll" "C:SolutionDirProjectDirbin" [C:SolutionDirProjectDirProject.csproj]
C:Program Files (x86)Microsoft Visual Studio2019ProfessionalMSBuildCurrentBinMicrosoft.Common.CurrentVersion.targets(1328,5): error MSB3073: copy "..ExtraDllsB.dll" "C:SolutionDirProjectDirbin" [C:SolutionDirProjectDirProject.csproj]
C:Program Files (x86)Microsoft Visual Studio2019ProfessionalMSBuildCurrentBinMicrosoft.Common.CurrentVersion.targets(1328,5): error MSB3073: " exited with code 1.
已经尝试在批处理文件中更改根目录。即,当root Directory设置一个包含msbuild.exe的root Directory时,仍然会遇到相同的问题。
用$(solutiondir(更新的设置参考无济于事。例如$(solutiondir(.. frectradlls b.dll
还有更多引用引用,但仅显示上述两个引用。尝试将相对路径更改为project.csproj文件中的绝对路径,但仍然相同的错误。因此,看起来它是从其他地方引用的。
在project.csproj文件中,在prebuildevent部分中,如果无法使用解决方案dir,则添加代码,然后使用。或实际检查以。开头的路径。
使用msbuild.exe命令传递属性/属性:solutiondir ="解决方案文件目录",该目录可以解决所有参考,现在正确复制了所有推出。
,例如
MSBuild /Property:SolutionDir=%SOL_DIR_PATH% %PROJECT_SLN_PATH%%PROJECT_DIRECTORY_NAME%%PROJECT_NAME% /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=%PUBLISH_DIRECTORY%%PROJECT_DIRECTORY_NAME%