发布通过脚本而不是Visual Studio中我的asp.net MVC应用程序 [英] Publishing my asp.net mvc application via script and not Visual Studio

查看:83
本文介绍了发布通过脚本而不是Visual Studio中我的asp.net MVC应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的不知道很多关于这跟你说实话...

I dont really know much about this to be honest with you...

我已成功地下载mscommunity构建和我已成功地使用下面的脚本成功编译和构建我的应用程序,但是,我想我的asp.net MVC应用程序上发表所以我想相同的文件,你的时候点击发布在Visual Studio中。我现在的build文件看起来像这样:

I have managed to download mscommunity build and I have managed to use the script below to successfully compile and build my application, however I want to get my asp.net mvc application "published" so I want the same files that you when clicking "publish" inside visual studio. My current build file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     <!-- Import the MSBuild Tasks -->
  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
    <ClassLibraryOutputDirectory>c:\publish\</ClassLibraryOutputDirectory>
    <ProjectDir>..\PetProject\</ProjectDir >
    <ProjectTestDir>$(ProjectDir)PetProject.WebUI\</ProjectTestDir >
    <ProjectFile>$(ProjectDir)PetProject.sln</ProjectFile >
    <TestProjectFile>$(ProjectTestDir)PetProject.WebUI.csproj</TestProjectFile >
  </PropertyGroup>

  <!-- Build projects by calling the Project files generated by VS -->
  <Target Name="Build">
    <MSBuild Projects="$(ProjectFile)" />
    <MSBuild Projects="$(TestProjectFile)" />
  </Target>

</Project>

我使用命令行称之为:

I call this in command line using:

C:\Windows\Microsoft.NET\Framework\v3.5>msbuild.exe C:\Projects\PetProject\build
\PetProject.build

帮助是极大的AP preciated ...

Help is greatly appreciated...

请注意:我想避免CI,南特等,因为我真的不知道他们是什么,我的理想想要得到上述工作作为一垒,然后移动到其他像CI或者其他,我不想迷惑自己太多...

NOTE: I want to avoid CI, Nant etc. because I dont really know what they are and I ideally want to get the above working as First Base, then move onto other things like CI or whatever else, I dont want to confuse myself too much...

推荐答案

这应该给你同样的结果在Visual Studio中发布:

This should give you the same result as publishing from within Visual Studio:

<Project DefaultTargets="BuildAndPublish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" />

    <PropertyGroup>
        <ProjectFile>C:\PetProject\PetProject.csproj</ProjectFile >
        <OutDir>C:\PetProject\MyPublish</OutDir>
    </PropertyGroup>

    <Target Name="BuildAndPublish">
        <MSBuild Projects="$(ProjectFile)" Targets="Package" Properties="Configuration=Release;PackageLocation=$(OutDir)\MSDeploy\Package.zip;_PackageTempDir=$(OutDir)\Temp" />
    </Target>

</Project>

为您的项目。

不要忘了导入 Microsoft.Web.Publishing.targets 包含套餐目标(我与混合起来发布在我的inital的答案)。

Don't forget to import Microsoft.Web.Publishing.targets which contains the Package target (which I mixed up with Publish in my inital answer).

如果你想建立自己的解决方案,你的脚本应该是这个样子:

If you want to build your solution your script should look something like this:

<Project DefaultTargets="BuildAndPublish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" />

    <PropertyGroup>
        <OutDir>C:\PetProject\MyPublish\</OutDir>
    </PropertyGroup>

    <ItemGroup>
        <Solution Include="C:\PetProject\PetProject.sln">
            <Properties>
                OutDir=$(OutDir);
                Platform=Any CPU;
                Configuration=Release;
                DeployOnBuild=True;
                DeployTarget=Package;
                PackageLocation=$(OutDir)\MSDeploy\Package.zip;
                _PackageTempDir=$(OutDir)\Temp
            </Properties>
        </Solution>
    </ItemGroup>

    <Target Name="BuildAndPublish">
        <MSBuild Projects="@(Solution)" />
    </Target>

</Project>

有的由$一篇博客文章C $内部c 基本上描述了同样的方法,但是当我在我的环境试过没有工作。

There's a blog post by Code Inside which describes basically the same approach but didn't work when I tried it in my environment.

这篇关于发布通过脚本而不是Visual Studio中我的asp.net MVC应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆