在另一台PC上部署.NET Console App

时间:2017-06-01 21:11:31

标签: c# .net

我今天制作了两个快速程序。我在这里展示的只是一个快速程序,它将虚拟机的日期更改为特定日期。我已经对它进行了测试并进行了部署,但无济于事,我无法让它在另一台机器上运行。我已按照this文档对我的工作进行了双重检查。两台PC都在运行.NET 4.7。我不确定问题是什么。任何帮助表示赞赏!

错误:

  

错误:未找到依赖项清单中指定的程序集 - package:' microsoft.codeanalysis.common',version:' 1.3.0',path:' LIB / netstandard1.3 / Microsoft.CodeAnalysis.dll'

Project.cs

using System; 
using System.IO; 
using System.Runtime.InteropServices; 
using System.Windows;

namespace vmRedundancy {

class Program {

    public struct SYSTEMTIME {
        public ushort wYear, wMonth, wDayOfWeek, wDay,
        wHour, wMinute, wSecond, wMilliseconds;
    }
    /// <param name="lpSystemTime">[out]</param>
    [DllImport ("kernel32.dll")]
    public extern static void GetSystemTime (ref SYSTEMTIME lpSystemTime);
    /// <param name="lpSystemTime">[in]</param>
    [DllImport ("kernel32.dll")]
    public extern static uint SetSystemTime (ref SYSTEMTIME lpSystemTime);

    static void Main (string[] args) {
        SYSTEMTIME st = new SYSTEMTIME();
        GetSystemTime(ref st);
        Console.WriteLine("The date was: " + st.wMonth + @"\" + st.wDay + @"\" + st.wYear); 
        st.wDay = 1;
        st.wMonth = 6;
        st.wYear = 2017;
        SetSystemTime(ref st);
        Console.WriteLine("The date is: " + st.wMonth + @"\" + st.wDay + @"\" + st.wYear); 
        //Console.WriteLine("The day of the week is: " + st.wDayOfWeek); 4
        Console.WriteLine("The time is: " + (st.wHour - 4) + ":" + st.wMinute + ":" + st.wSecond + " " + st.wMilliseconds + "ms"); 
            Console.ReadKey();
        }
    }
}

ChangeDateTime.json

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <RuntimeIdentifiers>win7-x64;win10-x64</RuntimeIdentifiers>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

</Project>

**发布:**

dotnet publish -r win7-x64

dotnet --info(部署)

  

.NET命令行工具(1.0.4)

     

产品信息:
    版本:1.0.4
    提交SHA-1哈希:af1e6684fd

     

运行时环境:
   操作系统名称:Windows
   操作系统版本:10.0.15063    OS平台:Windows
   RID:win10-x64
   基本路径:C:\ Program Files \ dotnet \ sdk \ 1.0.4

dotnet --info(客户端)

  

.NET命令行工具(1.0.4)

     

产品信息:
   版本:1.0.4
   提交SHA-1哈希:af1e6684fd

     

运行时环境:
   操作系统名称:Windows
   操作系统版本:6.1.7601
   OS平台:Windows
   RID:win7-x64
   基本路径:C:\ Program Files \ dotnet \ sdk \ 1.0.4

1 个答案:

答案 0 :(得分:0)

我能够通过下载和安装.NET 4.7 SDK并更改所有内容来完成这项工作。似乎很奇怪“核心”编译项目不能跨不同平台工作。我确信我误解了一些事情;我只是不知道是什么!

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
    <TargetFramework>net47</TargetFramework>
  </PropertyGroup>

</Project>